diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 6d0c5000c..bf0ac93bf 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -880,8 +880,24 @@ Partial Class Bancos_ProveedoresAbonar Dim tipoCambioCompra As Decimal Dim TipoCambioPago As Decimal = 0 Dim TipoCambioGeneral As Decimal = 0 - Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False) - + Dim tipoCambioCompraValuacion As Decimal = 1 + 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 FechaC As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day) + Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & FechaC & "#", "Fecha DESC") + + If drr IsNot Nothing Then + FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate + TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal + End If + + End If + End If 'inserto las compras que voy a pagar For Each gvr As GridViewRow In GvCxP.Rows @@ -895,11 +911,13 @@ Partial Class Bancos_ProveedoresAbonar 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 tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal + tipoCambioCompraValuacion = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal) PorcentajePago = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) / gvr.DataKey("Original").ToDecimal).RoundSQL ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES 'TipoCambioPago = 'GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal TipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal - tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal + tipoCambioCompraValuacion = 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 @@ -926,17 +944,17 @@ Partial Class Bancos_ProveedoresAbonar importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra + importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompraValuacion ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra + importeMX = gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompraValuacion ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - importeMX = ImporteMovimiento * tipoCambioCompra + importeMX = ImporteMovimiento * tipoCambioCompraValuacion End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - TipoCambioGeneral = tipoCambioCompra + TipoCambioGeneral = tipoCambioCompraValuacion ConceptoMovimiento = $"{HplProveedor.Text} F:{gvr.DataKey("SerieFolio")}" 'cuando son dolares, y tienen complementaria, se hace el registro If gvr.DataKey("CveMoneda").ToEntero = 1 Then @@ -948,7 +966,7 @@ Partial Class Bancos_ProveedoresAbonar CveCuenta = CveCuentaProveedorExtranjera If ImporteMovimiento <> 0 AndAlso (UsuarioActual.CveEmpresa = 119 Or IdCtaContable > 0) Then 'Cuando tiene complementaria lo dividimos en dos importeMX = ImporteMovimiento - If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0.00D, Referencia, 206, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=Math.Round(ImporteMovimiento * tipoCambioCompra - ImporteMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompra, CveCuenta:=CveCuentaComplementaria) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0.00D, Referencia, 206, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE, CveCompra:=gvr.DataKey("CveCompra").ToEntero, CveProveedor:=CveProveedor, ImporteMX:=Math.Round(ImporteMovimiento * tipoCambioCompraValuacion - ImporteMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioCompraValuacion, CveCuenta:=CveCuentaComplementaria) Then MsgError = "No se pudo insertar la póliza" End If End If @@ -961,12 +979,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra End If @@ -1007,18 +1027,20 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - TipoCambioGeneral = TipoCambioPago + TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" @@ -1041,12 +1063,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra End If @@ -1086,18 +1110,20 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - TipoCambioGeneral = TipoCambioPago + TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" @@ -1120,12 +1146,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento * tipoCambioCompra End If @@ -1165,18 +1193,20 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - TipoCambioGeneral = TipoCambioPago + TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" @@ -1199,18 +1229,20 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - TipoCambioGeneral = TipoCambioPago + TipoCambioGeneral = tipoCambioCompra If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" @@ -1233,18 +1265,20 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If ImporteMovimiento = Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero) importeMX = Math.Round(importeMX, 2, MidpointRounding.AwayFromZero) - TipoCambioGeneral = TipoCambioPago + TipoCambioGeneral = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) If TipoCambioPago > 1 Then ConceptoMovimiento += $" TC:{TipoCambioPago} ${ImporteMovimiento.FormatoNumero(2)}" @@ -1267,12 +1301,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If @@ -1300,12 +1336,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("RetIVA").ToDecimal * PorcentajePago importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = (gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If @@ -1517,12 +1555,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("IVA").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra End If @@ -1539,12 +1579,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra End If @@ -1579,12 +1621,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = gvr.DataKey("IVADeducible").ToDecimal * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = gvr.DataKey("IVADeducible").ToDecimal importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If @@ -1601,12 +1645,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVADeducible").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If @@ -1654,12 +1700,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra End If @@ -1680,12 +1728,14 @@ Partial Class Bancos_ProveedoresAbonar ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento ElseIf CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * tipoCambioCompra ElseIf CveMoneda = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + tipoCambioCompra = gvr.DataKey("TipoCambio").ToDecimal ImporteMovimiento = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) importeMX = ImporteMovimiento * If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) End If @@ -1700,49 +1750,101 @@ Partial Class Bancos_ProveedoresAbonar End If End If Case 64 'Ganancia - If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then - Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - - 'Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) - Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) - Dim IEPS As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) 'If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) - - IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria - Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - TipoCambioGeneral = TCImpuestos - '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra - If TipoCambioPago < tipoCambioCompra AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TipoCambioPago) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra) 'Añadimos la diferencia de ganancia en la venta - ImporteMovimiento -= (IVA * TCImpuestos) - (IVA * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA - ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA - ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR - ImporteMovimiento -= (IEPS * TCImpuestos) - (IEPS * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IEPS - ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)) - importeMX = ImporteMovimiento - End If + 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, tipoCambioCompraValuacion) + + + Dim Diferencia As Decimal = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioCompraValuacion) - ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * TipoCambioPago) 'Añadimos la diferencia de perdida en la venta + Diferencia -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA + Diferencia += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA + Diferencia += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR + Diferencia -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((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 + + + 'Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal + + ''Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + 'Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + 'Dim IEPS As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) 'If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) + + 'IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + 'CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + 'Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompraValuacion) + 'TipoCambioGeneral = TCImpuestos + ''' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra + 'If TipoCambioPago < tipoCambioCompra AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ' ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TipoCambioPago) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra) 'Añadimos la diferencia de ganancia en la venta + ' ImporteMovimiento -= (IVA * TCImpuestos) - (IVA * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IVA + ' ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetIVA + ' ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el RetISR + ' ImporteMovimiento -= (IEPS * TCImpuestos) - (IEPS * tipoCambioCompra) 'Añadimos la diferencia de ganancia en el IEPS + ' ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)) + ' importeMX = ImporteMovimiento + 'End If Else ImporteMovimiento = 0 End If Case 65 'Perdida If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then - Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) - Dim IEPS As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) 'If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) - IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria - Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra) - '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra - If TipoCambioPago > tipoCambioCompra AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then - ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TipoCambioPago) 'Añadimos la diferencia de ganancia en la venta - ImporteMovimiento -= (IVA * tipoCambioCompra) - (IVA * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA - ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA - ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR - ImporteMovimiento -= (IEPS * tipoCambioCompra) - (IEPS * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS - ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)) - importeMX = ImporteMovimiento + 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, tipoCambioCompra) + + Dim Diferencia As Decimal = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioCompraValuacion) - ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * TipoCambioPago) 'Añadimos la diferencia de perdida en la venta + Diferencia -= ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("IVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA + Diferencia += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA + Diferencia += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR + Diferencia -= ((gvr.DataKey("IEPS").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((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 + + 'Dim TotalImporte As Decimal = gvr.FCTextBox("TxtAbonar").Text.ToDecimal + 'Dim IVA As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IVAPorPagar").ToDecimal - (gvr.DataKey("IVA").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IVAPorPagar").ToDecimal, gvr.DataKey("IVA").ToDecimal * PorcentajePago) + 'Dim IEPS As Decimal = If(TotalImporte = gvr.DataKey("Saldo").ToDecimal AndAlso Math.Abs(Math.Round(gvr.DataKey("IEPSPorPagar").ToDecimal - (gvr.DataKey("IEPS").ToDecimal * PorcentajePago), 2)) <= 0.02, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) 'If(TotalImporte = gvr.DataKey("Saldo").ToDecimal, gvr.DataKey("IEPSPorPagar").ToDecimal, gvr.DataKey("IEPS").ToDecimal * PorcentajePago) + + 'IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + 'CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + 'Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompraValuacion) + '' si tiene funcionalidad de flucturación con ivas, tomar tipocambioCompra + 'If TipoCambioPago > tipoCambioCompra AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then + ' ImporteMovimiento = (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * tipoCambioCompra) - (gvr.FCTextBox("TxtAbonar").Text.ToDecimal * TipoCambioPago) 'Añadimos la diferencia de ganancia en la venta + ' ImporteMovimiento -= (IVA * tipoCambioCompra) - (IVA * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA + ' ImporteMovimiento += ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetIVA").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA + ' ImporteMovimiento += ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * tipoCambioCompra) - ((gvr.DataKey("RetISR").ToDecimal * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR + ' ImporteMovimiento -= (IEPS * tipoCambioCompra) - (IEPS * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS + ' ImporteMovimiento = Math.Abs(Math.Round(ImporteMovimiento, 2, MidpointRounding.AwayFromZero)) + ' importeMX = ImporteMovimiento + 'End If Else ImporteMovimiento = 0 End If diff --git a/Compras/EvaluacionProveedor.aspx.vb b/Compras/EvaluacionProveedor.aspx.vb index 6b2aef0a8..b842df48b 100644 --- a/Compras/EvaluacionProveedor.aspx.vb +++ b/Compras/EvaluacionProveedor.aspx.vb @@ -334,9 +334,10 @@ Partial Class Compras_EvaluacionProveedor ListaTagsDocumentost.Add(New TagsDocumentos("{{Proveedor}}", Proveedor)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Dia}}", Dia)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Mes}}", Mes)) + ListaTagsDocumentost.Add(New TagsDocumentos("{{Anio}}", Now.Year)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Calificacion}}", Calificacion)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Resultado}}", Resultado)) - ListaTagsDocumentost.Add(New TagsDocumentos("{{Usuario}}", UsuarioActual.Nombre)) + 'ListaTagsDocumentost.Add(New TagsDocumentos("{{Usuario}}", UsuarioActual.Nombre)) Dim MensajeInvitacion As String = "Le invitamos a participar en la implementación de acciones para la mejora de sus procesos." diff --git a/Empresas/13/Formatos/Plantillas/CartaProveedor.docx b/Empresas/13/Formatos/Plantillas/CartaProveedor.docx index 5d17cc4e6..5ae05f364 100644 Binary files a/Empresas/13/Formatos/Plantillas/CartaProveedor.docx and b/Empresas/13/Formatos/Plantillas/CartaProveedor.docx differ diff --git a/asmx/WsTSoft.asmx b/asmx/WsTSoft.asmx index 7d9e99ee5..626fdbb83 100644 --- a/asmx/WsTSoft.asmx +++ b/asmx/WsTSoft.asmx @@ -65,13 +65,20 @@ Public Class WsTSoft If Continuar Then 'CONSULTA DIRECCIONES Dim Direcciones As JArray = ConsultarDirecciones(ObjGPS.DtResultados, "Lat", "Lng") - For Each Dir As JObject In Direcciones - ObjGPS.DtResultados.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString() - Next - - ObjPos.Lat = ObjGPS.DtResultados.Rows("0")("Lat").ToString - ObjPos.Lng = ObjGPS.DtResultados.Rows("0")("Lng").ToString - ObjPos.Direccion = ObjGPS.DtResultados.Rows("0")("Direccion").ToString + Try + If Direcciones IsNot Nothing Then + For Each Dir As JObject In Direcciones + ObjGPS.DtResultados.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString() + Next + End If + + ObjPos.Lat = ObjGPS.DtResultados.Rows("0")("Lat").ToString + ObjPos.Lng = ObjGPS.DtResultados.Rows("0")("Lng").ToString + ObjPos.Direccion = ObjGPS.DtResultados.Rows("0")("Direccion").ToString + Catch ex As Exception + ObjPos.CurrentError = "No se pudo obtener la posición." + OnError("Ocurrió un error al asignar las direcciones", ex) + End Try Else ObjPos.CurrentError = "No se pudo obtener la posición." End If @@ -103,17 +110,25 @@ Public Class WsTSoft Dim Continuar As Boolean = objTsoft.GETRemisionesHistorial(FolioRemision, NoEconomico) Dim objRem As New GetRemisionHistorialesObj If Continuar Then - Dim Dt = objTsoft.DtResultados.Copy() - Dt.Columns.Add("Direccion", GetType(String)) + Try + Dim Dt = objTsoft.DtResultados.Copy() + Dt.Columns.Add("Direccion", GetType(String)) - 'CONSULTA DIRECCIONES - Dim Direcciones As JArray = ConsultarDirecciones(Dt, "Lat", "Lon") - For Each Dir As JObject In Direcciones - Dt.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString() - Next + 'CONSULTA DIRECCIONES + Dim Direcciones As JArray = ConsultarDirecciones(Dt, "Lat", "Lon") + If Direcciones IsNot Nothing Then + For Each Dir As JObject In Direcciones + Dt.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString() + Next + End If - objRem.Historial = Dt.DataTableToObject(Of GetRemisionHistorialsObj) - objRem.CurrentError = "" + objRem.Historial = Dt.DataTableToObject(Of GetRemisionHistorialsObj) + objRem.CurrentError = "" + Catch ex As Exception + objRem.CurrentError = "Ocurrió un error al asignar las direcciones" + OnError("Ocurrió un error al asignar las direcciones", ex) + End Try + Else objRem.Historial = New List(Of GetRemisionHistorialsObj) objRem.CurrentError = objTsoft.MyCurrentError @@ -129,11 +144,17 @@ Public Class WsTSoft Dim objTsoft As New ClsTSoft If objTsoft.GetInfoEventosPenske(FechaInicio.ToDateTime(), FechaFin.ToDateTime()) Then If objTsoft.DtResultados.Rows.Count > 0 Then - 'CONSULTA DIRECCIONES - Dim Direcciones As JArray = ConsultarDirecciones(objTsoft.DtResultados) - For Each Dir As JObject In Direcciones - objTsoft.DtResultados.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString() - Next + Try + 'CONSULTA DIRECCIONES + Dim Direcciones As JArray = ConsultarDirecciones(objTsoft.DtResultados) + If Direcciones IsNot Nothing Then + For Each Dir As JObject In Direcciones + objTsoft.DtResultados.Rows(Dir("Indice").ToEntero())("Direccion") = Dir("Direccion").ToString() + Next + End If + Catch ex As Exception + OnError("Ocurrió un error al asignar las direcciones", ex) + End Try retorno = objTsoft.DtResultados.DataTableToJSONIPP() Else