This commit is contained in:
Oscar Irigoyen
2023-05-25 18:52:49 -07:00
3 changed files with 112 additions and 51 deletions

View File

@@ -2401,6 +2401,9 @@ Namespace Modelos
tipoCambio = 1
End If
' Verificar si la fecha es del mes anterior a la fecha actual
Dim esMesAnterior As Boolean = False
If ObjFactura.TipoDocto = "Egs" AndAlso ValorMultiplicador = -1 AndAlso FechaCancelacion > MinFecha AndAlso tipoCambio > 1 AndAlso UsuarioActual.Empresa.Funcionalidad(703) = "1" Then
' Obtener el mes y año de la fecha actual
Dim mesActual As Integer = FechaCancelacion.Month
@@ -2409,23 +2412,11 @@ Namespace Modelos
' Obtener el mes y año de la fecha a comparar
Dim mesFecha As Integer = ObjFactura.Fecha.Month
Dim añoFecha As Integer = ObjFactura.Fecha.Year
' Verificar si la fecha es del mes anterior a la fecha actual
Dim esMesAnterior As Boolean = False
If añoFecha < añoActual Then
esMesAnterior = True
ElseIf añoFecha = añoActual AndAlso mesFecha < mesActual Then
esMesAnterior = True
End If
If esMesAnterior Then
Dim UltimaFluctuacion As ClsPaginas.MTipoCambioFluctuacion = ClsPaginas.GlobalTipoCambioUltimaFluctuacion(FechaCancelacion)
If UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion < FechaCancelacion Then
tipoCambio = UltimaFluctuacion.TCFluctuacion
End If
End If
End If
End If
Dim ConceptoContable As Integer
@@ -2719,8 +2710,27 @@ Namespace Modelos
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
Dim ConPreP As ClsPaginas.ConceptosTipoSaldo = ClsPaginas.ObtenerCveConceptoPrePoliza(6, ObjFactura.CveMoneda, False, 2)
Dim TipoCambioNC As Decimal = 1
If ObjFactura.CveMoneda = 2 Then
If tipoCambio > 1 Then
TipoCambioNC = tipoCambio
Else
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
End If
End If
If ValorMultiplicador = -1 AndAlso UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso esMesAnterior AndAlso ObjFactura.CveMoneda = 2 Then
Dim UltimaFluctuacion As ClsPaginas.MTipoCambioFluctuacion = ClsPaginas.GlobalTipoCambioUltimaFluctuacion(FechaCancelacion)
If UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion < FechaCancelacion Then
TipoCambioNC = UltimaFluctuacion.TCFluctuacion
End If
End If
End If
importeMovimiento = ObjFactura.Total * ValorMultiplicador
importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL(2)
importeMX = (importeMovimiento * TipoCambioNC * Multiplicador).RoundSQL(2)
FechaMovimiento = ObjFactura.FechaPago
CveSubProyectoContabilizar = ObjFactura.CveSubProyecto
@@ -2733,27 +2743,61 @@ Namespace Modelos
Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
End If
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConPreP.CveConcepto, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveSubProyecto:=CveSubProyectoContabilizar) Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConPreP.CveConcepto, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(TipoCambioNC = 1, 0, importeMovimiento), TipoCambio:=TipoCambioNC, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
If UsaComplementariaClientes AndAlso ObjFactura.CveMoneda = 2 Then
IdCtaContable = ObjFactura.Cliente.IdCtaContComplementaria
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, 0, Referencia, ConPreP.CveConceptoComplementario, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=(importeMovimiento * tipoCambio - importeMovimiento).RoundSQL(2), ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveSubProyecto:=CveSubProyectoContabilizar) Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, 0, Referencia, ConPreP.CveConceptoComplementario, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=(importeMovimiento * TipoCambioNC - importeMovimiento).RoundSQL(2), ImporteME:=If(TipoCambioNC = 1, 0, importeMovimiento), TipoCambio:=TipoCambioNC, CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
End If
End If
If ValorMultiplicador = -1 AndAlso esMesAnterior Then
Dim TCCliente As Decimal = tipoCambio
Dim TCFluctuacion As Decimal = tipoCambio
'TOMA EL TC DE LA ULTIMA FLUCTUACION
If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso ObjFactura.CveMoneda = 2 Then
Dim UltimaFluctuacion As ClsPaginas.MTipoCambioFluctuacion = ClsPaginas.GlobalTipoCambioUltimaFluctuacion(FechaCancelacion)
If UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion <= FechaCancelacion Then
TCCliente = UltimaFluctuacion.TCFluctuacion
TCFluctuacion = UltimaFluctuacion.TCFluctuacion
End If
End If
End If
'CONSIDERO FLUCTUACIÓN.
If tipoCambio <> TCFluctuacion AndAlso TCFluctuacion > 1 AndAlso tipoCambio > 1 Then
Dim difFluctuacion As Decimal = tipoCambio - TCFluctuacion
Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida
Dim TipoMovtoFluctua As Boolean = True
Dim IdCtaContableFluctua As Integer
If difFluctuacion < 0 Then
CveConceptoFluctua = 64
TipoMovtoFluctua = True
Else
CveConceptoFluctua = 65
TipoMovtoFluctua = False
End If
Dim ImporteFluctuacion As Decimal = Math.Abs((importeMovimiento * difFluctuacion).RoundSQL)
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=TCCliente) Then
ErrorPrepoliza = True
Exit For
End If
End If
End If
importeMovimiento = 0
If ValorMultiplicador = 1 Then
Dim IdCtaContableClienteComplementaria As Integer = ObjFactura.Cliente.IdCtaContComplementaria
Dim TipoCambioNC As Decimal = 1
If tipoCambio > 1 Then
TipoCambioNC = tipoCambio
Else
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
End If
'APLICA NC SALDOS DIRECTOS
If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
@@ -3023,15 +3067,19 @@ Namespace Modelos
If ValorMultiplicador = -1 Then
Dim TipoCambioNC As Decimal = 1
If tipoCambio > 1 Then
TipoCambioNC = tipoCambio
Else
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToDecimal
If ObjFactura.CveMoneda = 2 Then
If tipoCambio > 1 Then
TipoCambioNC = tipoCambio
Else
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToDecimal
Else
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
End If
End If
End If
'cuando es cancelación
If ObjFactura.DtNCVinculadas IsNot Nothing Then
For Each row2 As DataRow In ObjFactura.DtNCVinculadas.Rows
@@ -3056,7 +3104,7 @@ Namespace Modelos
Dim Pago As New ClsPaginas.VentaPago
Pago.Fecha = FechaCancelacion
Pago.FechaDocumentoRelacionado = FechaCancelacion
Pago.FechaDocumentoRelacionado = ObjFactura.Fecha
Pago.ImportePagoVenta = importeMovimiento
Pago.ImportePago = importeMovimiento
Pago.CveMonedaPago = ObjFactura.CveMoneda

View File

@@ -7111,7 +7111,7 @@ public partial class Nomina_Nomina2 : ClsPaginas
}
using (ClsRH objpersonal = new ClsRH())
{
if (objpersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, -1, fecha, fecha, UsuarioActual.CveEmpresa))
if (objpersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1,-1, fecha, fecha, UsuarioActual.CveEmpresa))
{
if (objpersonal.DtResultados.Rows.Count > 0)
{

View File

@@ -13825,6 +13825,7 @@ Partial Class Ventas
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
Dim CveCuentaContabilizacion As Integer = 1
Dim tipoCambio As Decimal
Dim TCPago As Decimal = 1
Dim CuentasContablesInvalidasSIG As New StringBuilder
@@ -13838,6 +13839,7 @@ Partial Class Ventas
If ObjFactura.CveMoneda = 2 AndAlso ObjFactura.TipoCambio > 0 Then
tipoCambio = ObjFactura.TipoCambio
TCPago = GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToString().ToDecimal
ElseIf ObjFactura.CveMoneda = 2 AndAlso ObjFactura.TipoCambio <= 1 Then
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
tipoCambio = GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToString().ToDecimal
@@ -14065,13 +14067,16 @@ Partial Class Ventas
End If
Dim TipoCambioNC As Decimal = 1
If tipoCambio > 1 Then
TipoCambioNC = tipoCambio
Else
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToDecimal
If ObjFactura.CveMoneda = 2 Then
If tipoCambio > 1 Then
TipoCambioNC = tipoCambio
Else
TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha.AddDays(-1)).ToDecimal
Else
TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
End If
End If
End If
@@ -14106,7 +14111,7 @@ Partial Class Ventas
Pago.CveVentaAmortizacion = ObjFactura.CveVenta 'Dr("CveVenta").ToString().ToEntero()
Pago.AplicaTraslado = False
Pago.Referencia = Concepto
Pago.CveConceptoPago = 251
'Pago.CveConceptoPago = 251
ErrorPrepoliza = AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
@@ -14137,11 +14142,14 @@ Partial Class Ventas
'SI LA NC ES EN DOLARES Y PERO VIENE DE UN ANTICIPO EN PESOS
If (Not UsuarioActual.CveEmpresa.Contiene(72, 80, 146)) AndAlso ObjFactura.CveMoneda = 2 Then
Dim tipoCambioAnticipo As Decimal = 1D
Dim tipoCambioAnticipo = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate).ToDecimal
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
tipoCambioAnticipo = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate.AddDays(-1)).ToDecimal
If CveMonedaAnticipo = 2 Then
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
tipoCambioAnticipo = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate.AddDays(-1)).ToDecimal
Else
tipoCambioAnticipo = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate).ToDecimal
End If
End If
@@ -14167,23 +14175,24 @@ Partial Class Ventas
End If
End If
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 292, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
'Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 292, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, Referencia, 292, Concepto, FechaMovimiento, ObjFactura.Cliente.IdCtaContMonedaExtranjera, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, CveIE:=CveIEAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
ErrorPrepoliza = True
Exit For
End If
'If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, Referencia, 292, Concepto, FechaMovimiento, ObjFactura.Cliente.IdCtaContMonedaExtranjera, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, CveIE:=CveIEAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
' ErrorPrepoliza = True
' Exit For
'End If
Else
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe11MX, Referencia, 11, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=row2.DataKey("CveVenta").ToEntero(), CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=Importe11MX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
Else
ViewState("SeGuardoPrePoliza") = True
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, Referencia, 2, Concepto, FechaMovimiento, ObjFactura.Cliente.IdCtaContClientes, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, CveIE:=CveIEAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
ErrorPrepoliza = True
Exit For
End If
'ViewState("SeGuardoPrePoliza") = True
'If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, Referencia, 2, Concepto, FechaMovimiento, ObjFactura.Cliente.IdCtaContClientes, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=importeMovimiento, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, CveIE:=CveIEAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
' ErrorPrepoliza = True
' Exit For
'End If
'se hace acreditamiento de impuestos
'IVA X TRASLADAR
Dim EsAnticipoEspecial As Boolean = False
@@ -16460,7 +16469,7 @@ Partial Class Ventas
Pago.CveVentaAmortizacion = gvr.DataKey("CveVenta").ToEntero()
Pago.AplicaTraslado = gvr.DataKey("RegresarImpuesto") = "1"
Pago.Referencia = gvr.DataKey("Folio")
Pago.CveConceptoPago = 251
'Pago.CveConceptoPago = 251
ErrorConta = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta)
SimplificaPrePoliza = False
@@ -19310,6 +19319,7 @@ Partial Class Ventas
DrPoliza("TotalImporte") = (DrPoliza("Cantidad").ToString().ToDecimal * PU).RoundSQL(NumeroDecimales)
DrPoliza("SATClaveProdServ") = DrPSAdicional("SATClavePS")
DrPoliza("SATClaveUM") = DrPSAdicional("SATClaveUnidadMedida")
DrPoliza("CveActivoFijo") = -1
TmpDT.Rows.Add(DrPoliza)
End If
@@ -21956,6 +21966,7 @@ Partial Class Ventas
drt("CveOSDetalle") = dr("CveOSDetalle")
drt("CveSubProyecto") = dr("CveSubProyecto")
drt("SubProyecto") = dr("SubProyecto")
drt("CveActivoFijo") = -1
TmpDT.Rows.Add(drt)
Cons = Cons + 1
Next
@@ -30085,6 +30096,7 @@ Partial Class Ventas
Row("CveVentaDetalleRNC") = CveVentaDetalleRNC
Row("CodigoObjetoImpuesto") = CodigoObjetoImpuesto
Row("CveActivoFijo") = -1
TmpDT.Rows.Add(Row)
End Sub
@@ -35008,6 +35020,7 @@ Partial Class Ventas
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
Row("CveActivoFijo") = -1
TmpDT.Rows.Add(Row)
End Sub