- conceptos de fluctuacion

This commit is contained in:
rrene
2020-04-23 20:56:17 -07:00
parent ba6b321d0f
commit 6e88c4fc26

View File

@@ -800,7 +800,7 @@ Partial Class Ventas_ClientesAbonar
'inserto las ventas que voy a pagar
For Each gvr As GridViewRow In GvCxC.Rows
If gvr.FCCheckBox("Chk").Checked Then
Dim ObjFactura As Modelos.Factura
Dim ObjFactura As Modelos.Factura = Nothing
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
ObjFactura = New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
@@ -1282,26 +1282,73 @@ Partial Class Ventas_ClientesAbonar
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
Dim CveMonedaVenta As Integer = gvr.DataKey("CveMoneda").ToEntero
Dim tImporteVenta, tImportePago As Decimal
Dim Diferencia As Decimal = 0
ImporteMovimiento = 0
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)
If CveMonedaVenta = 1 And CveMoneda <> 1 Then
'factura pesos, pago en dolares
tImporteVenta = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion).RoundSQL
tImportePago = (((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVenta / tipoCambioPago).RoundSQL * tipoCambioPago).RoundSQL
ElseIf CveMonedaVenta <> 1 And CveMoneda <> 1 Then
'factura dolares, pago en dolares
tImporteVenta = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion).RoundSQL
tImportePago = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioPago).RoundSQL
ElseIf CveMonedaVenta <> 1 And CveMoneda = 1 Then
'factura dolares, pago en pesos
tImporteVenta = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioVentaValuacion).RoundSQL
tImportePago = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioPago).RoundSQL
End If
If tImporteVenta <> tImportePago Then
If tImporteVenta < tImportePago Then
ConceptoContable = 64
IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
TipoMovimiento = True
'CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
Else
ConceptoContable = 65
IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
TipoMovimiento = False
' CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
End If
Diferencia = tImporteVenta - tImportePago
End If
' si tiene funcionalidad para que tome el TC de pago, que solo afecta a los impuestos
If FuncionalidadFluctuacionImpuestos Then
Dim TCImpuestos As Decimal = tipoCambioPago
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)
End If
ImporteMovimiento = Math.Abs(Diferencia)
importeMX = ImporteMovimiento
'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
'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
@@ -1318,47 +1365,47 @@ Partial Class Ventas_ClientesAbonar
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)
'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
' 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
' '' 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
@@ -1494,7 +1541,7 @@ Partial Class Ventas_ClientesAbonar
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
If MsgError = "" AndAlso 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