--mejora en manejo de fluctua
This commit is contained in:
@@ -39,7 +39,7 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
|
||||
Private Property CveUsuarioProgramo As Integer
|
||||
Get
|
||||
Return ViewState("CveUsuarioProgramo").ToString.ToEntero
|
||||
Return IfNull(ViewState("CveUsuarioProgramo"), "-1").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveUsuarioProgramo") = value
|
||||
@@ -1282,51 +1282,76 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
|
||||
Case 64 'Ganancia
|
||||
If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
|
||||
Dim tImporteCompra, tImportePago As Decimal
|
||||
Dim Diferencia As Decimal = 0
|
||||
|
||||
IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
|
||||
'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)
|
||||
|
||||
'' 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
|
||||
If gvr.DataKey("CveMoneda").ToEntero = 1 And CveMoneda <> 1 Then
|
||||
'factura pesos, pago en dolares
|
||||
tImporteCompra = gvr.FCTextBox("TxtAbonar").Text.ToDecimal.RoundSQL
|
||||
tImportePago = (((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioCompra / TipoCambioPago).RoundSQL * TipoCambioPago).RoundSQL
|
||||
ElseIf gvr.DataKey("CveMoneda").ToEntero <> 1 And CveMoneda <> 1 Then
|
||||
'factura dolares, pago en dolares
|
||||
tImporteCompra = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioCompraValuacion).RoundSQL
|
||||
tImportePago = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * TipoCambioPago).RoundSQL
|
||||
ElseIf gvr.DataKey("CveMoneda").ToEntero <> 1 And CveMoneda = 1 Then
|
||||
'factura dolares, pago en pesos
|
||||
tImporteCompra = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * tipoCambioCompraValuacion).RoundSQL
|
||||
tImportePago = ((gvr.FCTextBox("TxtAbonar").Text.ToDecimal) * TipoCambioPago).RoundSQL
|
||||
End If
|
||||
|
||||
If tImporteCompra <> tImportePago Then
|
||||
If tImporteCompra < 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 = tImporteCompra - tImportePago
|
||||
|
||||
End If
|
||||
|
||||
If FuncionalidadFluctuacionImpuestos Then
|
||||
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra)
|
||||
Diferencia = ((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 = Diferencia.RoundSQL
|
||||
End If
|
||||
|
||||
ImporteMovimiento = Math.Abs(Diferencia)
|
||||
importeMX = ImporteMovimiento
|
||||
|
||||
Else
|
||||
ImporteMovimiento = 0
|
||||
End If
|
||||
Case 65 'Perdida
|
||||
If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
|
||||
'Case 65 'Perdida
|
||||
' If CveMoneda <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
|
||||
|
||||
IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
|
||||
'tipoCambioVentaDiferenciaCambiaria = If(gvr.DataKey("Fecha").ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, gvr.DataKey("TipoCambio").ToDecimal)
|
||||
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPago, tipoCambioCompra)
|
||||
' IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
|
||||
' '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
|
||||
Else
|
||||
ImporteMovimiento = 0
|
||||
End If
|
||||
' 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
|
||||
' Else
|
||||
' ImporteMovimiento = 0
|
||||
' End If
|
||||
Case 255 'Otros egresos
|
||||
If DdlOtrosPagos.SelectedValue = "2" Then
|
||||
If CveMoneda = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
|
||||
@@ -1435,10 +1460,10 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
TipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
|
||||
End If
|
||||
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=If(TipoCambioPago = 1, 0, TxtImporte.Text.ToDecimal), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=If(TipoCambioPago = 1, 0, TxtImporte.Text.ToDecimal), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), Referencia, 204, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuentaBancariaComplementaria, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round((TxtImporte.Text.Trim.ToDecimal * TipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 1, 0, TxtImporte.Text.ToDecimal), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, If(CveMoneda = 1 AndAlso TxtTC.Visible, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, TxtImporte.Text.ToDecimal), Referencia, 204, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuentaBancariaComplementaria, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round((TxtImporte.Text.Trim.ToDecimal * TipoCambioPago) - TxtImporte.Text.Trim.ToDecimal, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(CveMoneda = 1, 0, TxtImporte.Text.ToDecimal), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
Else
|
||||
@@ -1448,7 +1473,7 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
TipoCambioPago = TxtTCDolaresDolares.Text.ToDecimal
|
||||
End If
|
||||
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round(TxtImporte.Text.Trim.ToDecimal * TipoCambioPago, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(DivTC.Visible, If(TxtTC.Text.ToDecimal > 0, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, 0), 0), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round(TxtImporte.Text.Trim.ToDecimal * TipoCambioPago, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(DivTC.Visible, If(TxtTC.Text.ToDecimal > 0, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, 0), 0), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
|
||||
@@ -1473,7 +1498,7 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
|
||||
ImporteFluctuacion = PagoProveedoresME - (Bancos + BancosComplementaria)
|
||||
|
||||
If ImporteFluctuacion.RoundSQL() <> 0 Then
|
||||
If MsgError = "" AndAlso ImporteFluctuacion.RoundSQL() <> 0 Then
|
||||
'SI EL PAGO DE PROVEEDORES ME ES MAYOR QUE BANCOS METER EL CONCEPTO DE GANANCIA
|
||||
If ImporteFluctuacion > 0 Then
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Math.Abs(ImporteFluctuacion), Referencia, 64, ConceptoMovimiento, TxtFechaIncobrable.Text.ToDate, IdCtaContable:=UsuarioActual.Empresa.IdCuentaGananciaCambiaria, CveIE:=-1, IdSegmentoNegocio:=-1, CveSubProyecto:=CveSubProyecto, CveProveedor:=Me.CveProveedor, CveCompra:=-1, ImporteMX:=Math.Abs(ImporteFluctuacion), TipoCambio:=TipoCambio, TipoCambioPago:=TCPago) Then
|
||||
@@ -1494,10 +1519,9 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
TipoCambioPago = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).ToString.ToDecimal
|
||||
End If
|
||||
|
||||
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round(TxtImporte.Text.Trim.ToDecimal * TipoCambioPago, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(DivTC.Visible, If(TxtTC.Text.ToDecimal > 0, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, 0), 0), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDecimal, Referencia, 30, ConceptoMovimiento, TxtFechaDocumento.Text.ToDate, IdCuenta, -1, CveIE, CveProveedor:=CveProveedor, ImporteMX:=If(CveMoneda = 2, Math.Round(TxtImporte.Text.Trim.ToDecimal * TipoCambioPago, 2, MidpointRounding.AwayFromZero), TxtImporte.Text.Trim.ToDecimal), ImporteME:=If(DivTC.Visible, If(TxtTC.Text.ToDecimal > 0, TxtImporte.Text.ToDecimal / TxtTC.Text.ToDecimal, 0), 0), TipoCambio:=TipoCambioPago, CveSubProyecto:=CveSubProyecto) Then
|
||||
MsgError = "No se pudo insertar la póliza"
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -1853,7 +1877,7 @@ Partial Class Bancos_ProveedoresAbonar
|
||||
DdlTipoTransaccion.SelectedValue = TipoPago.ToString
|
||||
RecargaCuentasDepositos()
|
||||
ElseIf TipoPago = 3 Then
|
||||
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2)and Estatus = 1 ")
|
||||
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo = 'Egs' AND CveTipoTransaccion IN (1, 2) and Estatus = 1 ")
|
||||
DdlTipoTransaccion.DataBind()
|
||||
DdlTipoTransaccion.SelectedValue = TipoPago.ToString
|
||||
RecargaCuentasDepositos()
|
||||
|
||||
Reference in New Issue
Block a user