Merge branch 'master' of http://192.168.10.111:8383/SIG
This commit is contained in:
@@ -2117,6 +2117,26 @@ Public Class ClsCompras
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
Public Function CancelarCompraOC(CveCompra As Integer, CveEmpresa As Integer) As Boolean
|
||||
|
||||
Dim Retorno As Boolean = False
|
||||
DataAdapter("PA_Comp_CancelarCompraOC")
|
||||
|
||||
With SqlAdapter.SelectCommand.Parameters
|
||||
.Add("@CveCompra", SqlDbType.Int).Value = CveCompra
|
||||
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
|
||||
End With
|
||||
|
||||
Try
|
||||
SqlAdapter.Fill(Data)
|
||||
Retorno = True
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al desvincular la oc de la compra.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
|
||||
End Try
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -7722,7 +7722,7 @@ Public Class ClsPaginas
|
||||
#End Region
|
||||
|
||||
#Region "P A G O D E V E N T A S "
|
||||
Public Function AplicaPrePolizaPagoVenta(VentaActual As Venta, Pago As VentaPago, CvePrePoliza As Integer, ByRef ObjConta As ClsContabilidad) As Boolean
|
||||
Public Shared Function AplicaPrePolizaPagoVenta(VentaActual As Venta, Pago As VentaPago, CvePrePoliza As Integer, ByRef ObjConta As ClsContabilidad) As Boolean
|
||||
Dim ErrorMovtos As Boolean = False
|
||||
Dim PorcentajePago As Decimal = Pago.ImportePagoVenta / VentaActual.Total
|
||||
Dim ImporteMovimiento As Decimal = 0
|
||||
@@ -7741,9 +7741,9 @@ Public Class ClsPaginas
|
||||
If Pago.TipoPago = "NC" Then Pago.CveConceptoPago = 301 Else Pago.CveConceptoPago = 292
|
||||
End If
|
||||
Dim Concepto As String = String.Format("{0} F:{1}", VentaActual.ClienteNombre, VentaActual.SerieFolio)
|
||||
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
|
||||
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(VentaActual.UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
|
||||
Dim tFecha As Date = Pago.Fecha
|
||||
If VentaActual.CveMoneda > 1 AndAlso UsuarioActual.Empresa.Funcionalidad(703) = "1" Then
|
||||
If VentaActual.CveMoneda > 1 AndAlso VentaActual.UsuarioActual.Empresa.Funcionalidad(703) = "1" Then
|
||||
Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
|
||||
If UltimaFluctuacion IsNot Nothing Then
|
||||
If UltimaFluctuacion.FechaFluctuacion < tFecha Then
|
||||
@@ -7767,7 +7767,7 @@ Public Class ClsPaginas
|
||||
End If
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = Pago.ImportePagoVenta
|
||||
'CONDICION ESPECIAL, PARA ANTICIPOS ESPECIALES, QUE SE EMITE LA VENTA, PERO NO SE CONTABILIZA, EL TRATAMIENTO SE LLEVA POR EL ANTICIPO
|
||||
If VentaActual.TipoDocto = "Ant" AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then
|
||||
If VentaActual.TipoDocto = "Ant" AndAlso VentaActual.UsuarioActual.CveEmpresa.Contiene(1, 119, 158) Then
|
||||
Pago.AplicaTraslado = False
|
||||
Dim IdCtaContable As Integer = VentaActual.IdCtaContableClienteAnticipo
|
||||
If VentaActual.CveMoneda = 2 Then IdCtaContable = VentaActual.IdCtaContableClienteAnticipoExtranjera
|
||||
@@ -7795,6 +7795,7 @@ Public Class ClsPaginas
|
||||
If Not ErrorMovtos AndAlso VentaActual.CveMoneda > 1 Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, (ImporteME * TCValuacionVenta - ImporteME).RoundSQL, CveConceptoContableComplementaria, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableClienteComplementaria, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacionVenta, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada, Contabilizable:=Contabilizable) Then ErrorMovtos = True
|
||||
End If
|
||||
|
||||
If Pago.AplicaTraslado Then
|
||||
'si tiene iva y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.IVA <> 0 Then
|
||||
@@ -7806,42 +7807,43 @@ Public Class ClsPaginas
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 61, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, PorcentajeImpuesto:=VentaActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
End If
|
||||
'si tiene RET IVA y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.RetIVA > 0 Then
|
||||
ImporteMovimiento = (PorcentajePago * VentaActual.RetIVA).RoundSQL
|
||||
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 8, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 62, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
'si tiene Ret ISR y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.RetISR > 0 Then
|
||||
ImporteMovimiento = (PorcentajePago * VentaActual.RetISR).RoundSQL
|
||||
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 9, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 63, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
'si tiene IEPS y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.IEPS > 0 Then
|
||||
ImporteMovimiento = (PorcentajePago * VentaActual.IEPS).RoundSQL
|
||||
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
|
||||
Dim Ret As New ConceptosRetenciones
|
||||
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
||||
If ObjConta.GetRetCuenta(38, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladar").ToString.ToEntero
|
||||
If ObjConta.GetRetCuenta(39, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSTrasladado").ToString.ToEntero
|
||||
'si tiene RET IVA y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.RetIVA > 0 Then
|
||||
ImporteMovimiento = (PorcentajePago * VentaActual.RetIVA).RoundSQL
|
||||
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 8, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 62, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
'si tiene Ret ISR y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.RetISR > 0 Then
|
||||
ImporteMovimiento = (PorcentajePago * VentaActual.RetISR).RoundSQL
|
||||
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 9, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * TCValuacionPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 63, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
'si tiene IEPS y su proporcion
|
||||
If Not ErrorMovtos AndAlso VentaActual.IEPS > 0 Then
|
||||
ImporteMovimiento = (PorcentajePago * VentaActual.IEPS).RoundSQL
|
||||
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
|
||||
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
|
||||
Dim Ret As New ConceptosRetenciones
|
||||
If VentaActual.UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
||||
If ObjConta.GetRetCuenta(38, VentaActual.UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladar").ToString.ToEntero
|
||||
If ObjConta.GetRetCuenta(39, VentaActual.UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSTrasladado").ToString.ToEntero
|
||||
End If
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 38, VentaActual.SerieFolio, Concepto, Ret.IdCtaContablexAcreditar, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * Pago.TCPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 39, VentaActual.SerieFolio, Concepto, Ret.IdCtaContableAcreditable, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 38, VentaActual.SerieFolio, Concepto, Ret.IdCtaContablexAcreditar, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
|
||||
If FuncionalidadFluctuacionImpuestos Then ImporteMN = (ImporteMovimiento * Pago.TCPago).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, 39, VentaActual.SerieFolio, Concepto, Ret.IdCtaContableAcreditable, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambio:=VentaActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME, CveSubProyecto:=VentaActual.CveSubProyecto, CveCompra:=Pago.CveCompraRelacionada) Then ErrorMovtos = True
|
||||
End If
|
||||
|
||||
'concepto pago
|
||||
Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
|
||||
If Pago.TipoPago = "A" AndAlso Not ErrorMovtos Then ' A N T I C I P O
|
||||
@@ -7870,13 +7872,13 @@ Public Class ClsPaginas
|
||||
End If
|
||||
If Pago.TipoPago = "I" AndAlso Not ErrorMovtos Then ' I N G R E S O S X C O M P R O B A R
|
||||
Dim Ret As New ConceptosRetenciones
|
||||
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
||||
If VentaActual.UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
||||
'If ObjConta.GetRetCuenta(66, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
|
||||
'If Pago.CveMonedaPago > 1 AndAlso ObjConta.GetRetCuenta(207, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").ToString.ToEntero
|
||||
If UsuarioActual.CveEmpresa.Contiene(119) Then
|
||||
If VentaActual.UsuarioActual.CveEmpresa.Contiene(119) Then
|
||||
If Pago.FechaDocumentoRelacionado.Year <= 2017 Then
|
||||
Dim ObjCliente As New ClsClientes(ObjConta.IniciaTransacSQL())
|
||||
If ObjCliente.GetClientes(VentaActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) AndAlso ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||
If ObjCliente.GetClientes(VentaActual.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, VentaActual.UsuarioActual.CveEmpresa) AndAlso ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||
If Pago.CveMonedaPago > 1 Then VentaActual.IdCtaContableClienteAnticipoExtranjera = ObjCliente.IdCtaContMonedaExtranjera Else VentaActual.IdCtaContableClienteAnticipo = ObjCliente.IdCtaContClientes
|
||||
End If
|
||||
End If
|
||||
@@ -7908,17 +7910,22 @@ Public Class ClsPaginas
|
||||
Dim ConceptoContable, IdCtaContable As Integer
|
||||
Dim TipoMovimiento As Boolean
|
||||
Dim Diferencia As Decimal = 0
|
||||
|
||||
'tImporteVenta = tImporteVenta.Abs()
|
||||
'tImportePago = tImportePago.Abs()
|
||||
|
||||
tImportePago += Pago.ImporteFluctuacionAdicional 'para los casos de aplicación de
|
||||
If tImporteVenta <> tImportePago Then
|
||||
If tImporteVenta < tImportePago Then
|
||||
If tImporteVenta.Abs() < tImportePago.Abs() Then
|
||||
ConceptoContable = 64
|
||||
TipoMovimiento = True
|
||||
Else
|
||||
ConceptoContable = 65
|
||||
TipoMovimiento = False
|
||||
End If
|
||||
Diferencia = (tImporteVenta - tImportePago).Abs.RoundSQL
|
||||
Diferencia = ((tImporteVenta - tImportePago).Abs.RoundSQL(2)) * Pago.ValorMultiplicador
|
||||
End If
|
||||
|
||||
If FuncionalidadFluctuacionImpuestos Then
|
||||
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, Pago.TCPago, VentaActual.TC)
|
||||
Diferencia = (Pago.ImportePago * VentaActual.TC) - (Pago.ImportePago * Pago.TCPago) 'Añadimos la diferencia de perdida en la venta
|
||||
@@ -7928,6 +7935,7 @@ Public Class ClsPaginas
|
||||
Diferencia -= ((VentaActual.IEPS * PorcentajePago) * VentaActual.TC) - ((VentaActual.IEPS * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IEPS
|
||||
Diferencia = Diferencia.Abs.RoundSQL
|
||||
End If
|
||||
|
||||
If Diferencia <> 0 Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, Diferencia, Diferencia, ConceptoContable, Concepto, Concepto, IdCtaContable, CveVenta:=VentaActual.CveVenta, CveSubProyecto:=VentaActual.CveSubProyecto, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE) Then
|
||||
ErrorMovtos = True
|
||||
@@ -7955,8 +7963,40 @@ Public Class ClsPaginas
|
||||
Public Property AplicaTraslado As Boolean = True
|
||||
Public Property Referencia As String
|
||||
Public Property ImporteFluctuacionAdicional As Decimal = 0
|
||||
Public Property ValorMultiplicador As Decimal = 1
|
||||
End Class
|
||||
Public Class Venta
|
||||
|
||||
Public Sub New(UsuarioActual As Usuario)
|
||||
Me.UsuarioActual = UsuarioActual
|
||||
End Sub
|
||||
Public Sub New(ObjFactura As Modelos.Factura, UsuarioActual As Usuario, Optional ValorMultiplicador As Decimal = 1D)
|
||||
Me.CveVenta = ObjFactura.CveVenta
|
||||
Me.CveCliente = ObjFactura.CveCliente
|
||||
Me.CveMoneda = ObjFactura.CveMoneda
|
||||
Me.TipoDocto = ObjFactura.TipoDocto
|
||||
Me.SerieFolio = ObjFactura.SerieFolio
|
||||
Me.Fecha = ObjFactura.Fecha
|
||||
|
||||
If ObjFactura.Cliente IsNot Nothing AndAlso ObjFactura.CveCliente > 0 Then
|
||||
Me.ClienteNombre = ObjFactura.Cliente.Nombre
|
||||
Me.IdCtaContableCliente = If(ObjFactura.CveMoneda = 1, ObjFactura.Cliente.IdCtaContClientes, ObjFactura.Cliente.IdCtaContMonedaExtranjera)
|
||||
Me.IdCtaContableClienteComplementaria = ObjFactura.Cliente.IdCtaContComplementaria
|
||||
Me.IdCtaContableClienteAnticipo = ObjFactura.Cliente.IdCtaContAnticipos
|
||||
Me.IdCtaContableClienteAnticipoExtranjera = ObjFactura.Cliente.IdCtaMonedaExtranjeraAnticipos
|
||||
Me.IdCtaContableClienteAnticipoComplementaria = ObjFactura.Cliente.IdCtaContCompAnticipos
|
||||
End If
|
||||
|
||||
Me.TC = ObjFactura.TipoCambio
|
||||
Me.Total = ObjFactura.Total * ValorMultiplicador
|
||||
Me.IVA = ObjFactura.IVA * ValorMultiplicador
|
||||
Me.IEPS = ObjFactura.IEPS * ValorMultiplicador
|
||||
Me.RetIVA = ObjFactura.RetIVA * ValorMultiplicador
|
||||
Me.RetISR = ObjFactura.RetISR * ValorMultiplicador
|
||||
Me.PorcentajeIVA = ObjFactura.PorcentajeIVA.ToString().ToDecimal()
|
||||
Me.CveSubProyecto = ObjFactura.CveSubProyecto
|
||||
Me.UsuarioActual = ObjFactura.UsuarioActual
|
||||
End Sub
|
||||
Public Property CveVenta As Integer = -1
|
||||
Public Property CveCliente As Integer
|
||||
Public Property CveMoneda As Integer
|
||||
|
||||
@@ -2371,7 +2371,7 @@ Namespace Modelos
|
||||
Private Function ProcesoPrepolizas(ObjFactura As Factura, ByRef ObjConta As ClsContabilidad, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi,
|
||||
Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing,
|
||||
Optional ByRef DtRemisionesRelacionadas As DataTable = Nothing, Optional SeCancelaRemisionProceso As Boolean = False, Optional CancelarRemisiones As Boolean = False, Optional ListaRemisionesCancelar As List(Of Integer) = Nothing,
|
||||
Optional CveEstatusRefacturacion As Integer = 0, Optional ByRef ObjInventario As ClsInventarios = Nothing) As Boolean
|
||||
Optional CveEstatusRefacturacion As Integer = 0, Optional ByRef ObjInventario As ClsInventarios = Nothing, Optional FechaCancelacion As DateTime = MinFecha) As Boolean
|
||||
Dim ErrorPrepoliza As Boolean = False
|
||||
Try
|
||||
Dim DT As DataTable
|
||||
@@ -2401,6 +2401,33 @@ Namespace Modelos
|
||||
tipoCambio = 1
|
||||
End If
|
||||
|
||||
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
|
||||
Dim añoActual As Integer = FechaCancelacion.Year
|
||||
|
||||
' 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
|
||||
Dim TipoMovimiento As Boolean
|
||||
Dim importeMovimiento As Decimal
|
||||
@@ -2690,46 +2717,33 @@ Namespace Modelos
|
||||
|
||||
Case 12 'Nota de Credito
|
||||
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
|
||||
Dim ConPreP As ClsPaginas.ConceptosTipoSaldo = ClsPaginas.ObtenerCveConceptoPrePoliza(6, ObjFactura.CveMoneda, False, 2)
|
||||
|
||||
importeMovimiento = ObjFactura.Total * ValorMultiplicador
|
||||
importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL
|
||||
importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL(2)
|
||||
FechaMovimiento = ObjFactura.FechaPago
|
||||
Dim ImporteConcepto12 As Decimal = 0
|
||||
Dim ImporteAcumulado91 As Decimal = 0
|
||||
Dim CveUltimaVenta As Integer = 0
|
||||
If tipoCambio > 1 Then
|
||||
Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
ConceptoContable = 293
|
||||
End If
|
||||
IdCtaContable = 0
|
||||
If tipoCambio = 1 Then
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||
ElseIf UsaComplementariaClientes Then
|
||||
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContComplementaria
|
||||
CveSubProyectoContabilizar = ObjFactura.CveSubProyecto
|
||||
|
||||
If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsaComplementariaClientes) Then
|
||||
importeMX = importeMovimiento
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, 0, Referencia, 203, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=(importeMovimiento * tipoCambio - importeMovimiento).RoundSQL, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
End If
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||
|
||||
If ObjFactura.CveMoneda = 2 Then
|
||||
importeMX = importeMovimiento
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera
|
||||
Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
End If
|
||||
CveSubProyectoContabilizar = CveSubProyectoVenta
|
||||
ImporteConcepto12 = importeMX.RoundSQL
|
||||
If importeMovimiento <> 0 Then
|
||||
If IdCtaContable <= 0 Then
|
||||
CuentasContablesInvalidas.Append("<br>" & ClsPaginas.GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString)
|
||||
idCuentaContabilizacion = 0
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), 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(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, 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
|
||||
ErrorPrepoliza = True
|
||||
Else
|
||||
ObjFactura.SeGuardoPrePoliza = True
|
||||
End If
|
||||
End If
|
||||
|
||||
importeMovimiento = 0
|
||||
|
||||
If ValorMultiplicador = 1 Then
|
||||
@@ -2740,109 +2754,41 @@ Namespace Modelos
|
||||
Else
|
||||
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
|
||||
End If
|
||||
|
||||
'APLICA NC SALDOS DIRECTOS
|
||||
If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
|
||||
For Each Dr As DataRow In DtVentasNC.Rows
|
||||
Dim Importe91 As Decimal = 0
|
||||
Dim ImporteMN91 As Decimal = 0
|
||||
Dim Importe251 As Decimal = 0
|
||||
Dim ObjFacturaRef As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
|
||||
|
||||
If ObjFactura.CveMoneda = 1 AndAlso Not Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString.ToDecimal
|
||||
Importe91 = Dr("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString.ToDecimal
|
||||
TipoCambioNC = 1
|
||||
ElseIf ObjFactura.CveMoneda = 2 AndAlso Not Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString.ToDecimal * TipoCambioNC
|
||||
Importe91 = Dr("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString.ToDecimal * TipoCambioNC
|
||||
ElseIf ObjFactura.CveMoneda = 2 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString.ToDecimal
|
||||
Importe91 = Dr("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString.ToDecimal * TipoCambioNC
|
||||
ElseIf ObjFactura.CveMoneda = 1 AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString.ToDecimal / TipoCambioNC
|
||||
Importe91 = Dr("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString.ToDecimal
|
||||
End If
|
||||
Dim ventaRef As New ClsPaginas.Venta(ObjFacturaRef, UsuarioActual, ValorMultiplicador:=ValorMultiplicador)
|
||||
|
||||
Importe251 = (Importe251 * Multiplicador).RoundSQL
|
||||
ObjFacturaRef.Dispose()
|
||||
|
||||
Importe91 = (Importe91 * ValorMultiplicador).RoundSQL
|
||||
ImporteMN91 = (ImporteMN91 * Multiplicador).RoundSQL
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${Importe91.FormatoNumero(2)}"
|
||||
ventaRef.ClienteNombre = ObjFactura.Cliente.Nombre
|
||||
ventaRef.IdCtaContableCliente = If(ventaRef.CveMoneda = 1, ObjFactura.Cliente.IdCtaContClientes, ObjFactura.Cliente.IdCtaContMonedaExtranjera)
|
||||
ventaRef.IdCtaContableClienteComplementaria = ObjFactura.Cliente.IdCtaContComplementaria ' ViewState("IdCtaContComplementaria").ToString.ToEntero
|
||||
|
||||
CveUltimaVenta = Dr("CveVenta").ToString.ToEntero
|
||||
ventaRef.IdCtaContableClienteAnticipo = ObjFactura.Cliente.IdCtaContAnticipos
|
||||
ventaRef.IdCtaContableClienteAnticipoExtranjera = ObjFactura.Cliente.IdCtaMonedaExtranjeraAnticipos
|
||||
ventaRef.IdCtaContableClienteAnticipoComplementaria = ObjFactura.Cliente.IdCtaContCompAnticipos
|
||||
|
||||
Dim ImporteComplementarioIngreso As Decimal = 0
|
||||
If UsaComplementariaClientes = True AndAlso tipoCambio > 1 Then
|
||||
ImporteMN91 = Importe91
|
||||
ImporteComplementarioIngreso = ((Importe91 * tipoCambio) - Importe91).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 203, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteComplementarioIngreso, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=Dr("TCCambioValuacion").ToString.ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteMN91, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
ImporteAcumulado91 += (ImporteMN91).RoundSQL
|
||||
Dim Pago As New ClsPaginas.VentaPago
|
||||
Pago.Fecha = ObjFactura.Fecha
|
||||
Pago.FechaDocumentoRelacionado = ObjFactura.Fecha
|
||||
Pago.ImportePagoVenta = Dr("Importe").ToString().ToDecimal()
|
||||
Pago.ImportePago = Dr("Importe").ToString().ToDecimal()
|
||||
Pago.CveMonedaPago = ObjFactura.CveMoneda
|
||||
Pago.TCPago = TipoCambioNC
|
||||
Pago.TipoPago = "NC"
|
||||
Pago.CveVentaAmortizacion = ObjFactura.CveVenta 'Dr("CveVenta").ToString().ToEntero()
|
||||
Pago.AplicaTraslado = False
|
||||
Pago.Referencia = Concepto
|
||||
Pago.CveConceptoPago = 251
|
||||
|
||||
Dim tCveConcepto As Integer = 251
|
||||
If Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then tCveConcepto = 301
|
||||
If UsaComplementariaClientes = True AndAlso Dr("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Dim ImporteComplementarioNC As Decimal = ((Importe251 * Dr("TCCambioValuacion").ToString.ToDecimal) - Importe251).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 207, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=Dr("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementarioNC, ImporteME:=If(Dr("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString.ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, tCveConcepto, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=Importe251, ImporteME:=If(Dr("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString.ToDecimal, TipoCambioPago:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
|
||||
'considero fluctuación.
|
||||
|
||||
Dim TCFluctuacion As Decimal = Dr("TCCambioValuacion").ToString.ToDecimal
|
||||
If TCFluctuacion = 1 AndAlso TipoCambioNC > 1 Then
|
||||
TCFluctuacion = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
|
||||
End If
|
||||
If TipoCambioNC <> TCFluctuacion AndAlso TCFluctuacion > 1 AndAlso TipoCambioNC > 1 Then
|
||||
Dim difFluctuacion As Decimal = TipoCambioNC - TCFluctuacion
|
||||
Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida
|
||||
Dim TipoMovtoFluctua As Boolean = True
|
||||
Dim IdCtaContableFluctua As Integer
|
||||
If difFluctuacion < 0 Then
|
||||
CveConceptoFluctua = 65
|
||||
TipoMovtoFluctua = False
|
||||
Else
|
||||
CveConceptoFluctua = 64
|
||||
TipoMovtoFluctua = True
|
||||
End If
|
||||
Dim ImporteFluctuacion As Decimal = Math.Abs((Importe251 * difFluctuacion).RoundSQL) * ValorMultiplicador
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString.ToEntero, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=TipoCambioNC, TipoCambioPago:=Dr("TCCambioValuacion").ToString.ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
|
||||
|
||||
Next
|
||||
|
||||
If ImporteConcepto12 < ImporteAcumulado91 Then
|
||||
Dim ImporteOtrosIngresos As Decimal = ImporteConcepto12 - ImporteAcumulado91
|
||||
If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ImporteOtrosIngresos, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveUltimaVenta, ImporteMX:=ImporteOtrosIngresos, ImporteME:=0, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, ImporteOtrosIngresos, Referencia, 211, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteME:=0, ImporteMX:=ImporteOtrosIngresos, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
Else
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 5) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
ErrorPrepoliza = True
|
||||
@@ -2855,7 +2801,6 @@ Namespace Modelos
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If ErrorPrepoliza Then
|
||||
Exit For
|
||||
End If
|
||||
@@ -3078,6 +3023,16 @@ Namespace Modelos
|
||||
Dim Contabilizable = If(UsuarioActual.CveEmpresa = 119, False, True)
|
||||
|
||||
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
|
||||
Else
|
||||
TipoCambioNC = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
|
||||
End If
|
||||
End If
|
||||
'cuando es cancelación
|
||||
If ObjFactura.DtNCVinculadas IsNot Nothing Then
|
||||
For Each row2 As DataRow In ObjFactura.DtNCVinculadas.Rows
|
||||
@@ -3085,134 +3040,43 @@ Namespace Modelos
|
||||
If row2("CveConceptoContable").ToString().ToEntero.Contiene(91, 294) Then
|
||||
|
||||
importeMovimiento = (row2("Importe").ToString().ToDecimal * ValorMultiplicador)
|
||||
sumaAmorticaciones += importeMovimiento
|
||||
|
||||
Dim CveConceptoAplicacionNC As Integer = 91
|
||||
Dim CveConceptoPagoNC As Integer = 251
|
||||
Dim ObjFacturaRef As New Modelos.Factura(UsuarioActual, row2("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
|
||||
|
||||
If tipoCambio > 1 Then
|
||||
Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
CveConceptoAplicacionNC = 294
|
||||
CveConceptoPagoNC = 301
|
||||
Dim ventaRef As New ClsPaginas.Venta(ObjFacturaRef, UsuarioActual, ValorMultiplicador:=-1D)
|
||||
|
||||
ObjFacturaRef.Dispose()
|
||||
|
||||
ventaRef.ClienteNombre = ObjFactura.Cliente.Nombre
|
||||
ventaRef.IdCtaContableCliente = If(ventaRef.CveMoneda = 1, ObjFactura.Cliente.IdCtaContClientes, ObjFactura.Cliente.IdCtaContMonedaExtranjera)
|
||||
ventaRef.IdCtaContableClienteComplementaria = ObjFactura.Cliente.IdCtaContComplementaria ' ViewState("IdCtaContComplementaria").ToString.ToEntero
|
||||
|
||||
ventaRef.IdCtaContableClienteAnticipo = ObjFactura.Cliente.IdCtaContAnticipos
|
||||
ventaRef.IdCtaContableClienteAnticipoExtranjera = ObjFactura.Cliente.IdCtaMonedaExtranjeraAnticipos
|
||||
ventaRef.IdCtaContableClienteAnticipoComplementaria = ObjFactura.Cliente.IdCtaContCompAnticipos
|
||||
|
||||
Dim Pago As New ClsPaginas.VentaPago
|
||||
Pago.Fecha = FechaCancelacion
|
||||
Pago.FechaDocumentoRelacionado = FechaCancelacion
|
||||
Pago.ImportePagoVenta = importeMovimiento
|
||||
Pago.ImportePago = importeMovimiento
|
||||
Pago.CveMonedaPago = ObjFactura.CveMoneda
|
||||
Pago.TCPago = TipoCambioNC
|
||||
Pago.TipoPago = "NC"
|
||||
Pago.CveVentaAmortizacion = ObjFactura.CveVenta 'Dr("CveVenta").ToString().ToEntero()
|
||||
Pago.AplicaTraslado = False
|
||||
Pago.Referencia = Concepto
|
||||
Pago.CveConceptoPago = 251
|
||||
Pago.ValorMultiplicador = -1D
|
||||
|
||||
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
|
||||
|
||||
If ErrorPrepoliza Then
|
||||
Exit For
|
||||
End If
|
||||
|
||||
'CTACONTABLE
|
||||
'IdCtaContable = IdCtaContAnticipos
|
||||
|
||||
If tipoCambio = 1 Then
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||
Else
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera
|
||||
End If
|
||||
|
||||
CveSubProyectoContabilizar = CveSubProyectoVenta
|
||||
|
||||
If importeMovimiento <> 0 Then
|
||||
|
||||
Dim Importe91 As Decimal = 0
|
||||
Dim ImporteMN91 As Decimal = 0
|
||||
Dim Importe251 As Decimal = 0
|
||||
Dim ImporteMN251 As Decimal = 0
|
||||
|
||||
If ObjFactura.CveMoneda = 1 AndAlso Not row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = row2("Importe").ToString.ToDecimal
|
||||
Importe91 = row2("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = row2("Importe").ToString.ToDecimal
|
||||
tipoCambio = 1
|
||||
ElseIf ObjFactura.CveMoneda = 2 AndAlso Not row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = row2("Importe").ToString.ToDecimal
|
||||
Importe91 = row2("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = row2("Importe").ToString.ToDecimal * tipoCambio
|
||||
ElseIf ObjFactura.CveMoneda = 2 AndAlso row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = row2("Importe").ToString.ToDecimal
|
||||
Importe91 = row2("Importe").ToString.ToDecimal
|
||||
ImporteMN91 = row2("Importe").ToString.ToDecimal * tipoCambio
|
||||
ElseIf ObjFactura.CveMoneda = 1 AndAlso row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
|
||||
Importe91 = row2("Importe").ToString.ToDecimal / tipoCambio
|
||||
ImporteMN91 = row2("Importe").ToString.ToDecimal
|
||||
End If
|
||||
|
||||
Dim TCFluctuacion As Decimal = row2("TCCambioValuacion").ToString.ToDecimal
|
||||
|
||||
If TCFluctuacion = 1 AndAlso tipoCambio > 1 Then
|
||||
TCFluctuacion = ClsPaginas.GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
|
||||
End If
|
||||
|
||||
If ObjFactura.CveMoneda = 2 AndAlso Not row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
ImporteMN251 = row2("Importe").ToString.ToDecimal * TCFluctuacion
|
||||
ElseIf ObjFactura.CveMoneda = 2 AndAlso row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
ImporteMN251 = row2("Importe").ToString.ToDecimal * TCFluctuacion
|
||||
ElseIf ObjFactura.CveMoneda = 1 AndAlso row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
Importe251 = row2("Importe").ToString.ToDecimal / TCFluctuacion
|
||||
ImporteMN251 = row2("Importe").ToString.ToDecimal
|
||||
Else
|
||||
ImporteMN251 = row2("Importe").ToString.ToDecimal
|
||||
End If
|
||||
|
||||
Importe251 = (Importe251 * Multiplicador * ValorMultiplicador).RoundSQL
|
||||
ImporteMN251 = ImporteMN251 * ValorMultiplicador
|
||||
Importe91 = (Importe91 * ValorMultiplicador).RoundSQL
|
||||
ImporteMN91 = (ImporteMN91 * Multiplicador * ValorMultiplicador).RoundSQL
|
||||
|
||||
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${Importe91.FormatoNumero(2)}"
|
||||
|
||||
Dim CveUltimaVenta = row2("CveVenta").ToString.ToEntero
|
||||
|
||||
Dim ImporteComplementarioIngreso As Decimal = 0
|
||||
If UsaComplementariaClientes = True AndAlso tipoCambio > 1 Then
|
||||
ImporteMN91 = Importe91
|
||||
ImporteComplementarioIngreso = ((Importe91 * tipoCambio) - Importe91).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 203, Concepto, FechaMovimiento, ObjFactura.Cliente.IdCtaContComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, ImporteMX:=ImporteComplementarioIngreso, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=row2("TCCambioValuacion").ToString.ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, CveConceptoAplicacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, ImporteMX:=ImporteMN91, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
|
||||
If UsaComplementariaClientes = True AndAlso row2("TCCambioValuacion").ToString.ToDecimal > 1 Then
|
||||
ImporteMN251 = Importe251
|
||||
Dim ImporteComplementarioNC As Decimal = ((Importe251 * row2("TCCambioValuacion").ToString.ToDecimal) - Importe251).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 207, Concepto, FechaMovimiento, ObjFactura.Cliente.IdCtaContComplementaria, -1, CveVenta:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementarioNC, ImporteME:=If(row2("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=row2("TCCambioValuacion").ToString.ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, CveConceptoPagoNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteMN251, ImporteME:=If(row2("TCCambioValuacion").ToString.ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=row2("TCCambioValuacion").ToString.ToDecimal, TipoCambioPago:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
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 = 65
|
||||
TipoMovtoFluctua = False
|
||||
Else
|
||||
CveConceptoFluctua = 64
|
||||
TipoMovtoFluctua = True
|
||||
End If
|
||||
Dim ImporteFluctuacion As Decimal = Math.Abs((Importe251 * difFluctuacion).RoundSQL) * ValorMultiplicador
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=row2("TCCambioValuacion").ToString.ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
End If
|
||||
|
||||
@@ -5342,7 +5206,7 @@ Namespace Modelos
|
||||
'CANCELA PREPOLIZA
|
||||
If Not ErrorCancelar Then
|
||||
ErrorCancelar = ProcesoPrepolizas(ObjFactura, ObjConta, -1, ObjFactura.DtDetalle, ObjAC, -1, ObjBancos, ObjVentas, ObjEventos, DtRemisionesRelacionadas:=DtRemisionesRelacionadas, SeCancelaRemisionProceso:=SeCancelaRemisionProceso,
|
||||
CancelarRemisiones:=CancelarRemisiones, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveEstatusRefacturacion:=CveEstatusRefacturacion, ObjInventario:=ObjInventario)
|
||||
CancelarRemisiones:=CancelarRemisiones, ListaRemisionesCancelar:=ListaRemisionesCancelar, CveEstatusRefacturacion:=CveEstatusRefacturacion, ObjInventario:=ObjInventario, FechaCancelacion:=CancelacionFecha)
|
||||
MensajeError = "Ocurrió un error al generar la prepoliza de cancelación."
|
||||
End If
|
||||
|
||||
@@ -7693,6 +7557,8 @@ Namespace Modelos
|
||||
Public Property IdCtaContMonedaExtranjera As Integer
|
||||
Public Property IdCtaContComplementaria As Integer
|
||||
Public Property IdCtaContAnticipos As Integer
|
||||
Public Property IdCtaMonedaExtranjeraAnticipos As Integer
|
||||
Public Property IdCtaContCompAnticipos As Integer
|
||||
Public Property IdCtaContRetIVA As Integer
|
||||
Public Property IdCtaContRetISR As Integer
|
||||
Public Property ConvenioCIE As String
|
||||
|
||||
@@ -1584,7 +1584,7 @@ Partial Class Bancos_PopIECompras
|
||||
End If
|
||||
|
||||
If MsgError = "" Then
|
||||
Dim VentaActual As New Venta With {.CveVenta = rw.DataKey("CveVenta").ToEntero, .ClienteNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveCliente = rw.DataKey("CveCliente").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero}
|
||||
Dim VentaActual As New Venta(UsuarioActual) With {.CveVenta = rw.DataKey("CveVenta").ToEntero, .ClienteNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveCliente = rw.DataKey("CveCliente").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero}
|
||||
Dim PagoVenta As New VentaPago
|
||||
|
||||
PagoVenta.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
|
||||
|
||||
@@ -13949,6 +13949,12 @@ Partial Class Compras_Compras
|
||||
|
||||
End If
|
||||
|
||||
If Not ErrorCancelar Then
|
||||
If Not ObjCompras.CancelarCompraOC(CveCompra, UsuarioActual.CveEmpresa) Then
|
||||
ErrorCancelar = True
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
'CANCELA COMPRA
|
||||
If Not ErrorCancelar Then
|
||||
|
||||
@@ -966,7 +966,7 @@ Partial Class Ventas_ClientesAbonar
|
||||
ObjFactura = New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
|
||||
End If
|
||||
|
||||
Dim VentaActual As New Venta
|
||||
Dim VentaActual As New Venta(UsuarioActual)
|
||||
VentaActual.CveVenta = gvr.DataKey("CveVenta").ToEntero
|
||||
VentaActual.Fecha = gvr.DataKey("Fecha").ToDate
|
||||
VentaActual.CveCliente = gvr.DataKey("CveCliente").ToEntero
|
||||
@@ -982,7 +982,6 @@ Partial Class Ventas_ClientesAbonar
|
||||
VentaActual.RetISR = gvr.DataKey("RetISR").ToDecimal
|
||||
|
||||
VentaActual.PorcentajeIVA = gvr.DataKey("PorcentajeIVA").ToDecimal
|
||||
VentaActual.UsuarioActual = UsuarioActual
|
||||
VentaActual.CveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero
|
||||
VentaActual.IdCtaContableCliente = IIf(VentaActual.CveMoneda = 1, IdCuentaCliente, IdCtaContMonedaExtranjera)
|
||||
VentaActual.IdCtaContableClienteComplementaria = IdCtaContComplementaria
|
||||
|
||||
@@ -5277,7 +5277,7 @@ Partial Class Ventas
|
||||
TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString().PadLeft(6, "0"c)
|
||||
|
||||
|
||||
VentaActual = New Venta
|
||||
VentaActual = New Venta(UsuarioActual)
|
||||
VentaActual.CveVenta = CveVenta
|
||||
VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate
|
||||
VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero
|
||||
@@ -10079,8 +10079,38 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
'ContPAQ El movimiento 1 es el de Venta
|
||||
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
|
||||
|
||||
AutoConta = AutocontaMatriz(AutoConta)
|
||||
|
||||
If DdlTipoComprobante.SelectedValue.Contiene("Rem", "RNC", "Cot", "Ped", "Pd2", "PA") Then
|
||||
AutoConta = False
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then
|
||||
AutoConta = False
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveEmpresa = 140 Then
|
||||
AutoConta = True
|
||||
idCuentaContabilizacion = 10
|
||||
End If
|
||||
|
||||
Try
|
||||
If AutoConta Then
|
||||
If Not ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
||||
ErrorList.Add("Ocurrió un error al contabilizar, pongase en contacto con soporte técnico")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ErrorList.Add("Ocurrió un error al contabilizar, pongase en contacto con soporte técnico")
|
||||
OnError("Ocurrió un error al contabilizar la factura", ex)
|
||||
End Try
|
||||
|
||||
If ObjFactura.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or ObjFactura.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
|
||||
ObjVentas.Commit()
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
||||
|
||||
'ENVIAR POLIZA VIRTUAL
|
||||
If ErrorList.Count = 0 Then
|
||||
@@ -10089,42 +10119,6 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
'ContPAQ El movimiento 1 es el de Venta
|
||||
Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1"
|
||||
|
||||
AutoConta = AutocontaMatriz(AutoConta)
|
||||
|
||||
If UsuarioActual.CveEmpresa = 119 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ant", "Rem", "RNC", "Cot", "Ped", "Pd2", "PA", "Egs", "Dev") Then
|
||||
AutoConta = False
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveEmpresa = 140 Then
|
||||
AutoConta = True
|
||||
idCuentaContabilizacion = 10
|
||||
End If
|
||||
|
||||
Try
|
||||
If AutoConta Then
|
||||
If idCuentaContabilizacion > 0 Or UsuarioActual.CveEmpresa.Contiene(7, 11, 12, 122, 145) Then
|
||||
If ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
||||
Else
|
||||
Alert("Ocurrió un Error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
End If
|
||||
Else
|
||||
Alert(String.Format("Falta asignación de las siguientes cuentas contables: {0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
Else
|
||||
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al contabilizar la factura", ex)
|
||||
End Try
|
||||
|
||||
Try
|
||||
'RMF, cuando es pedido, se manda autorización.
|
||||
If ObjFactura.TipoDocto.Contiene("PA") Then
|
||||
@@ -14043,456 +14037,294 @@ Partial Class Ventas
|
||||
|
||||
Case 12 'Nota de Credito
|
||||
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
|
||||
Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, ObjFactura.CveMoneda, False, 2)
|
||||
|
||||
importeMovimiento = ObjFactura.Total * ValorMultiplicador
|
||||
importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL
|
||||
importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL(2)
|
||||
FechaMovimiento = ObjFactura.FechaPago
|
||||
Dim ImporteConcepto12 As Decimal = 0
|
||||
Dim ImporteAcumulado91 As Decimal = 0
|
||||
Dim CveUltimaVenta As Integer = 0
|
||||
If tipoCambio > 1 Then
|
||||
Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
ConceptoContable = 293
|
||||
End If
|
||||
If tipoCambio = 1 Then
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||
ElseIf UsaComplementariaClientes Then
|
||||
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContComplementaria
|
||||
CveSubProyectoContabilizar = ObjFactura.CveSubProyecto
|
||||
|
||||
If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsaComplementariaClientes) Then
|
||||
importeMX = importeMovimiento
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, 0, Referencia, 203, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=Math.Round(importeMovimiento * tipoCambio - importeMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
End If
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||
|
||||
If ObjFactura.CveMoneda = 2 Then
|
||||
importeMX = importeMovimiento
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContMonedaExtranjera
|
||||
'CveCuenta = ObjFactura.Cliente.CveCuentaMonedaExtranjera
|
||||
Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
End If
|
||||
CveSubProyectoContabilizar = CveSubProyectoVenta
|
||||
ImporteConcepto12 = importeMX.RoundSQL
|
||||
If importeMovimiento <> 0 Then
|
||||
If IdCtaContable <= 0 Then
|
||||
CuentasContablesInvalidas.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString())
|
||||
idCuentaContabilizacion = 0
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), 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(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, 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
|
||||
ErrorPrepoliza = True
|
||||
Else
|
||||
ViewState("SeGuardoPrePoliza") = True
|
||||
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
|
||||
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
|
||||
Else
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
|
||||
TipoCambioNC = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToDecimal
|
||||
Else
|
||||
TipoCambioNC = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
|
||||
End If
|
||||
|
||||
TipoCambioNC = GlobalTipoCambio(ObjFactura.Fecha).ToDecimal
|
||||
End If
|
||||
End If
|
||||
|
||||
'APLICA NC SALDOS DIRECTOS
|
||||
If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
|
||||
For Each Dr As DataRow In DtVentasNC.Rows
|
||||
importeMovimiento = 0
|
||||
importeMX = 0
|
||||
|
||||
'APLICA NC SALDOS DIRECTOS
|
||||
If Not ErrorPrepoliza AndAlso DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
|
||||
For Each Dr As DataRow In DtVentasNC.Rows
|
||||
Dim ObjFacturaRef As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
|
||||
|
||||
Dim Importe91 As Decimal = 0
|
||||
Dim ImporteMN91 As Decimal = 0
|
||||
Dim Importe251 As Decimal = 0
|
||||
Dim ImporteMN251 As Decimal = 0
|
||||
Dim ventaRef As New Venta(ObjFacturaRef, UsuarioActual)
|
||||
|
||||
If DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso Not Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString().ToDecimal
|
||||
Importe91 = Dr("Importe").ToString().ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString().ToDecimal
|
||||
TipoCambioNC = 1
|
||||
ElseIf DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso Not Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString().ToDecimal
|
||||
Importe91 = Dr("Importe").ToString().ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString().ToDecimal * TipoCambioNC
|
||||
ElseIf DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString().ToDecimal
|
||||
Importe91 = Dr("Importe").ToString().ToDecimal
|
||||
ImporteMN91 = Dr("Importe").ToString().ToDecimal * TipoCambioNC
|
||||
ElseIf DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
ObjFacturaRef.Dispose()
|
||||
|
||||
Importe91 = Dr("Importe").ToString().ToDecimal / TipoCambioNC
|
||||
ImporteMN91 = Dr("Importe").ToString().ToDecimal
|
||||
End If
|
||||
ventaRef.ClienteNombre = NombreCliente
|
||||
ventaRef.IdCtaContableCliente = IIf(ventaRef.CveMoneda = 1, ViewState("IdCtaContClientes"), ViewState("IdCtaContMonedaExtranjera")).ToString.ToEntero
|
||||
ventaRef.IdCtaContableClienteComplementaria = ViewState("IdCtaContComplementaria").ToString.ToEntero
|
||||
|
||||
Dim TCFluctuacion As Decimal = Dr("TCCambioValuacion").ToString().ToDecimal
|
||||
If TCFluctuacion = 1 AndAlso TipoCambioNC > 1 Then
|
||||
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
|
||||
TCFluctuacion = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToDecimal
|
||||
Else
|
||||
TCFluctuacion = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
|
||||
End If
|
||||
End If
|
||||
ventaRef.IdCtaContableClienteAnticipo = ViewState("IdCtaContAnticipos").ToString.ToEntero
|
||||
ventaRef.IdCtaContableClienteAnticipoExtranjera = ViewState("IdCtaContAnticiposExtranjera").ToString.ToEntero
|
||||
ventaRef.IdCtaContableClienteAnticipoComplementaria = ViewState("IdCtaContAnticiposComplementaria").ToString.ToEntero
|
||||
|
||||
If DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso Not Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
ImporteMN251 = Dr("Importe").ToString().ToDecimal * TCFluctuacion
|
||||
ElseIf DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
ImporteMN251 = Dr("Importe").ToString().ToDecimal * TCFluctuacion
|
||||
ElseIf DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
Importe251 = Dr("Importe").ToString().ToDecimal / TCFluctuacion
|
||||
ImporteMN251 = Dr("Importe").ToString().ToDecimal
|
||||
Else
|
||||
ImporteMN251 = Dr("Importe").ToString().ToDecimal
|
||||
End If
|
||||
|
||||
Importe251 = Importe251.RoundSQL
|
||||
|
||||
Importe91 = (Importe91).RoundSQL
|
||||
ImporteMN91 = (ImporteMN91 * Multiplicador).RoundSQL
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${Importe91.FormatoNumero(2)}"
|
||||
|
||||
CveUltimaVenta = Dr("CveVenta").ToString().ToEntero()
|
||||
|
||||
Dim ImporteComplementarioIngreso As Decimal = 0
|
||||
If UsaComplementariaClientes = True AndAlso tipoCambio > 1 Then
|
||||
ImporteMN91 = Importe91
|
||||
ImporteComplementarioIngreso = ((Importe91 * tipoCambio) - Importe91).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, 203, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString().ToEntero(), ImporteMX:=ImporteComplementarioIngreso, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=Dr("TCCambioValuacion").ToString().ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
Dim CveConceptoAplicacionNC As Integer = 91
|
||||
'SI LA NOTA DE CREDITO ES EN MONEDA EXTRANGERA UTILIZAR EL CONCEPTO DE APLICACION ME
|
||||
If ConceptoContable = 293 Then
|
||||
CveConceptoAplicacionNC = 294
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe91, Referencia, CveConceptoAplicacionNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString().ToEntero(), ImporteMX:=ImporteMN91, ImporteME:=If(tipoCambio = 1, 0, Importe91), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
ImporteAcumulado91 += (ImporteMN91).RoundSQL
|
||||
|
||||
If UsaComplementariaClientes = True AndAlso Dr("TCCambioValuacion").ToString().ToDecimal > 1 Then
|
||||
ImporteMN251 = Importe251
|
||||
Dim ImporteComplementarioNC As Decimal = ((Importe251 * Dr("TCCambioValuacion").ToString().ToDecimal) - Importe251).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 207, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementarioNC, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
' Traslado de impuestos cuando es amortizacion de NC
|
||||
If EsNCAmortizacion Then
|
||||
'' aqui no se registra el pago como NC, se deja para el registro de la aplicaion del anticipo
|
||||
'' esto para trasladar los impuestos.
|
||||
|
||||
If Not AplicoNCFacturaActual Then
|
||||
If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") Then
|
||||
|
||||
For Each row2 As GridViewRow In GVAnticipos.Rows
|
||||
If row2.DataKey("CveConceptoContable").ToString().ToEntero() = 3 Then
|
||||
If row2.FCCheckBox("Chk" & row2.RowIndex).Checked Then
|
||||
CveIEAnticipo = row2.DataKey("CveIE").ToString().ToEntero()
|
||||
importeMovimiento = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal)
|
||||
Dim ImporteAnticipo As Decimal = importeMovimiento
|
||||
Dim CveMonedaAnticipo As Integer = row2.DataKey("CveMoneda").ToString().ToEntero()
|
||||
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
|
||||
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then ImporteAnticipo = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal * row2.DataKey("SubTotalAnticipo").ToDecimal
|
||||
|
||||
Dim Importe11MX As Decimal = ImporteAnticipo
|
||||
|
||||
IdCtaContable = IdCtaContAnticipos
|
||||
CveSubProyectoContabilizar = CveSubProyectoVenta
|
||||
|
||||
If importeMovimiento <> 0 Then
|
||||
|
||||
'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 = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate).ToDecimal
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
|
||||
tipoCambioAnticipo = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate.AddDays(-1)).ToDecimal
|
||||
End If
|
||||
|
||||
|
||||
If ObjFactura.CveMoneda = 2 AndAlso CveMonedaAnticipo = 1 Then
|
||||
Importe11MX = Importe11MX * tipoCambio
|
||||
End If
|
||||
|
||||
If row2.DataKey("CveMoneda").ToString.ToEntero = 2 Then
|
||||
IdCtaContable = IdCtaContAnticiposExtranjera
|
||||
End If
|
||||
|
||||
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(tipoCambioAnticipo = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioAnticipo) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If row2.DataKey("CveMoneda").ToString.ToEntero = 2 Then
|
||||
IdCtaContable = IdCtaContAnticiposComplementaria
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ImporteAnticipo * tipoCambioAnticipo - ImporteAnticipo, Referencia, 227, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=row2.DataKey("CveVenta").ToEntero(), CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=ImporteAnticipo * tipoCambioAnticipo - ImporteAnticipo, ImporteME:=If(tipoCambioAnticipo = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioAnticipo) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
'se hace acreditamiento de impuestos
|
||||
'IVA X TRASLADAR
|
||||
Dim EsAnticipoEspecial As Boolean = False
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(1, 119) Then EsAnticipoEspecial = True
|
||||
If EsAnticipoEspecial Then
|
||||
Dim PorcentajeImpuestoPago As Decimal = TmpDT.MAX("PorcentajeIVA").ToDecimal
|
||||
'' si se esta aplicando NC por amortizaion, se trasladan impuestos
|
||||
If EsNCAmortizacion Then
|
||||
Dim IngresoIVA As Decimal = TxtIVA.Text.ToDecimal
|
||||
Dim IngresoIEPS As Decimal = TxtIEPS.Text.ToDecimal
|
||||
Dim IngresoTotal As Decimal = TxtTotal.Text.ToDecimal
|
||||
|
||||
If IngresoIVA > 0 Then
|
||||
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 13, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, (importeMovimiento * IngresoIVA) / IngresoTotal, Referencia, 13, Concepto, Fecha, IdCtaIVAXTrasladar, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIVA) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
'IVA PAGADO
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 61, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, (importeMovimiento * IngresoIVA) / IngresoTotal, Referencia, 61, Concepto, Fecha, IdCtaIVATrasladado, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIVA) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If IngresoIEPS > 0 Then
|
||||
'IEPS X TRASLADAR
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 38, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If IngresoIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, (importeMovimiento * IngresoIEPS) / IngresoTotal, Referencia, 38, Concepto, Fecha, 0, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIEPS) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
'IEPS PAGADO
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 39, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If IngresoIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, (importeMovimiento * IngresoIEPS) / IngresoTotal, Referencia, 39, Concepto, Fecha, 0, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIEPS) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
ElseIf AplicoNCFacturaActual AndAlso ChkAplicaNCAnticipo.Checked Then
|
||||
|
||||
Dim CveConceptoPagoNC As Integer = 251
|
||||
If ObjFactura.CveMoneda > 1 Then
|
||||
CveConceptoPagoNC = 301
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, CveConceptoPagoNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteMN251, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
Dim CveConceptoPagoNC As Integer = 251
|
||||
If ObjFactura.CveMoneda > 1 Then
|
||||
CveConceptoPagoNC = 301
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, CveConceptoPagoNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteMN251, ImporteME:=If(Dr("TCCambioValuacion").ToString().ToDecimal = 1, 0, Importe251), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=Dr("TCCambioValuacion").ToString().ToDecimal, TipoCambioPago:=tipoCambio) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
'considero fluctuación.
|
||||
|
||||
|
||||
If TipoCambioNC <> TCFluctuacion AndAlso TCFluctuacion > 1 AndAlso TipoCambioNC > 1 Then
|
||||
Dim difFluctuacion As Decimal = TipoCambioNC - TCFluctuacion
|
||||
Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida
|
||||
Dim TipoMovtoFluctua As Boolean = True
|
||||
Dim IdCtaContableFluctua As Integer
|
||||
If difFluctuacion < 0 Then
|
||||
CveConceptoFluctua = 65
|
||||
TipoMovtoFluctua = False
|
||||
Else
|
||||
CveConceptoFluctua = 64
|
||||
TipoMovtoFluctua = True
|
||||
End If
|
||||
Dim ImporteFluctuacion As Decimal = Math.Abs((Importe251 * difFluctuacion).RoundSQL)
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=Dr("CveVenta").ToString().ToEntero(), ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=TipoCambioNC, TipoCambioPago:=Dr("TCCambioValuacion").ToString().ToDecimal) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
If ImporteConcepto12 <> ImporteAcumulado91 Then
|
||||
Dim CveConceptoOtIngresos As Integer = 0
|
||||
Dim IdCuentaContableOt As Integer = 0
|
||||
Dim TipoMovtoOt As Boolean = False
|
||||
|
||||
If ImporteConcepto12 > ImporteAcumulado91 Then
|
||||
IdCuentaContableOt = UsuarioActual.Empresa.Funcionalidad(559).ToEntero()
|
||||
CveConceptoOtIngresos = 211
|
||||
TipoMovtoOt = False
|
||||
Else
|
||||
IdCuentaContableOt = UsuarioActual.Empresa.IdCuentaOtrosIngresos
|
||||
CveConceptoOtIngresos = 78
|
||||
TipoMovtoOt = True
|
||||
End If
|
||||
|
||||
|
||||
Dim ImporteOtrosIngresos As Decimal = ImporteConcepto12 - ImporteAcumulado91
|
||||
' If ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ImporteOtrosIngresos, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveUltimaVenta, ImporteMX:=ImporteOtrosIngresos, ImporteME:=0, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio) Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoOt, ImporteOtrosIngresos, Referencia, CveConceptoOtIngresos, Concepto, FechaMovimiento, IdCuentaContableOt, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, ImporteME:=0, ImporteMX:=ImporteOtrosIngresos, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
'Else
|
||||
' ErrorPrepoliza = True
|
||||
'End If
|
||||
End If
|
||||
|
||||
If Not ErrorPrepoliza AndAlso ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 5) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
'ErrorPrepoliza = True
|
||||
GuardaLogAD($"Ventas/Ventas-ProcesoPrePolizas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{ObjFactura.CvePrePoliza}", "LogPrePolizas")
|
||||
|
||||
'SIRVE PARA VER LA PREPOLIZA QUE SE VALIDA
|
||||
'If ObjConta.GetPrePolizasDetalle(ObjFactura.CvePrePoliza) Then
|
||||
' Dim DtTest = ObjConta.DtResultados
|
||||
'End If
|
||||
End If
|
||||
End If
|
||||
Dim Pago As New VentaPago
|
||||
Pago.Fecha = ObjFactura.Fecha
|
||||
Pago.FechaDocumentoRelacionado = ObjFactura.Fecha
|
||||
Pago.ImportePagoVenta = Dr("Importe").ToString().ToDecimal()
|
||||
Pago.ImportePago = Dr("Importe").ToString().ToDecimal()
|
||||
Pago.CveMonedaPago = ObjFactura.CveMoneda
|
||||
Pago.TCPago = TipoCambioNC
|
||||
Pago.TipoPago = "NC"
|
||||
Pago.CveVentaAmortizacion = ObjFactura.CveVenta 'Dr("CveVenta").ToString().ToEntero()
|
||||
Pago.AplicaTraslado = False
|
||||
Pago.Referencia = Concepto
|
||||
Pago.CveConceptoPago = 251
|
||||
|
||||
ErrorPrepoliza = AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
|
||||
|
||||
If ErrorPrepoliza Then
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
'APLICA DEVOLUCION SALDOS DIRECTOS
|
||||
If AplicaDevolucion Then
|
||||
Dim importeMovimientoDev = TxtTotal.Text.ToDecimal
|
||||
importeMovimientoDev = If(SaldoVentaDevolucion < importeMovimientoDev, SaldoVentaDevolucion, importeMovimientoDev)
|
||||
If importeMovimientoDev > 0 Then
|
||||
Dim importeMXDev = importeMovimientoDev * tipoCambio * Multiplicador
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimientoDev.FormatoNumero(2)}"
|
||||
If Not ErrorPrepoliza AndAlso EsNCAmortizacion AndAlso Not AplicoNCFacturaActual AndAlso DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") Then
|
||||
|
||||
If UsaComplementariaClientes AndAlso tipoCambio > 1 Then
|
||||
importeMXDev = importeMovimientoDev
|
||||
Dim ImporteComplementaria As Decimal = ((importeMovimientoDev * tipoCambio) - importeMovimientoDev).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, importeMovimientoDev, Referencia, 203, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveVentaDevolucion, ImporteMX:=ImporteComplementaria, ImporteME:=If(tipoCambio = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=TipoCambioFactura) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
For Each row2 As GridViewRow In GVAnticipos.Rows
|
||||
If row2.DataKey("CveConceptoContable").ToString().ToEntero() = 3 Then
|
||||
If row2.FCCheckBox("Chk" & row2.RowIndex).Checked Then
|
||||
CveIEAnticipo = row2.DataKey("CveIE").ToString().ToEntero()
|
||||
importeMovimiento = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal)
|
||||
Dim ImporteAnticipo As Decimal = importeMovimiento
|
||||
Dim CveMonedaAnticipo As Integer = row2.DataKey("CveMoneda").ToString().ToEntero()
|
||||
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
|
||||
|
||||
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then ImporteAnticipo = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal * row2.DataKey("SubTotalAnticipo").ToDecimal
|
||||
|
||||
Dim Importe11MX As Decimal = ImporteAnticipo
|
||||
|
||||
IdCtaContable = IdCtaContAnticipos
|
||||
CveSubProyectoContabilizar = CveSubProyectoVenta
|
||||
|
||||
If importeMovimiento <> 0 Then
|
||||
|
||||
'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 = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate).ToDecimal
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(13, 83) Then
|
||||
tipoCambioAnticipo = GlobalTipoCambio(row2.DataKey("Fecha").ToString().ToDate.AddDays(-1)).ToDecimal
|
||||
End If
|
||||
|
||||
|
||||
If ObjFactura.CveMoneda = 2 AndAlso CveMonedaAnticipo = 1 Then
|
||||
Importe11MX = Importe11MX * tipoCambio
|
||||
End If
|
||||
|
||||
If row2.DataKey("CveMoneda").ToString.ToEntero = 2 Then
|
||||
IdCtaContable = IdCtaContAnticiposExtranjera
|
||||
End If
|
||||
|
||||
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(tipoCambioAnticipo = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioAnticipo) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If row2.DataKey("CveMoneda").ToString.ToEntero = 2 Then
|
||||
IdCtaContable = IdCtaContAnticiposComplementaria
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, ImporteAnticipo * tipoCambioAnticipo - ImporteAnticipo, Referencia, 227, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=row2.DataKey("CveVenta").ToEntero(), CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=ImporteAnticipo * tipoCambioAnticipo - ImporteAnticipo, ImporteME:=If(tipoCambioAnticipo = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioAnticipo) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
'se hace acreditamiento de impuestos
|
||||
'IVA X TRASLADAR
|
||||
Dim EsAnticipoEspecial As Boolean = False
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(1, 119) Then EsAnticipoEspecial = True
|
||||
If EsAnticipoEspecial Then
|
||||
Dim PorcentajeImpuestoPago As Decimal = TmpDT.MAX("PorcentajeIVA").ToDecimal
|
||||
'' si se esta aplicando NC por amortizaion, se trasladan impuestos
|
||||
If EsNCAmortizacion Then
|
||||
Dim IngresoIVA As Decimal = TxtIVA.Text.ToDecimal
|
||||
Dim IngresoIEPS As Decimal = TxtIEPS.Text.ToDecimal
|
||||
Dim IngresoTotal As Decimal = TxtTotal.Text.ToDecimal
|
||||
|
||||
If IngresoIVA > 0 Then
|
||||
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 13, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, (importeMovimiento * IngresoIVA) / IngresoTotal, Referencia, 13, Concepto, Fecha, IdCtaIVAXTrasladar, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIVA) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
'IVA PAGADO
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 61, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, (importeMovimiento * IngresoIVA) / IngresoTotal, Referencia, 61, Concepto, Fecha, IdCtaIVATrasladado, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIVA) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, PorcentajeImpuesto:=PorcentajeImpuestoPago) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If IngresoIEPS > 0 Then
|
||||
'IEPS X TRASLADAR
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 38, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If IngresoIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, (importeMovimiento * IngresoIEPS) / IngresoTotal, Referencia, 38, Concepto, Fecha, 0, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIEPS) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
'IEPS PAGADO
|
||||
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 39, NombreCliente, Dr("Folio").ToString, FolioIE.ToString())
|
||||
If IngresoIEPS > 0 AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, (importeMovimiento * IngresoIEPS) / IngresoTotal, Referencia, 39, Concepto, Fecha, 0, -1, CveVenta:=Dr("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=((importeMovimiento * IngresoIEPS) / IngresoTotal) * tipoCambio * Multiplicador, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, importeMovimientoDev, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveVentaDevolucion, ImporteMX:=importeMXDev, ImporteME:=If(tipoCambio = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If UsaComplementariaClientes AndAlso TipoCambioFactura > 1 Then
|
||||
importeMXDev = importeMovimientoDev
|
||||
Dim ImporteComplementaria As Decimal = ((importeMovimientoDev * TipoCambioFactura) - importeMovimientoDev).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimientoDev, Referencia, 207, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=CveVentaDevolucion, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementaria, ImporteME:=If(TipoCambioFactura = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=TipoCambioFactura) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim CveConceptoPagoNC As Integer = 251
|
||||
If ObjFactura.CveMoneda > 1 Then
|
||||
CveConceptoPagoNC = 301
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimientoDev, Referencia, CveConceptoPagoNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVentaDevolucion, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteMX:=importeMXDev, ImporteME:=If(tipoCambio = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If tipoCambio <> TipoCambioFactura Then
|
||||
Dim difFluctuacion As Decimal = tipoCambio - TipoCambioFactura
|
||||
Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida
|
||||
Dim TipoMovtoFluctua As Boolean = True
|
||||
Dim IdCtaContableFluctua As Integer
|
||||
If difFluctuacion < 0 Then
|
||||
CveConceptoFluctua = 65
|
||||
TipoMovtoFluctua = False
|
||||
Else
|
||||
CveConceptoFluctua = 64
|
||||
TipoMovtoFluctua = True
|
||||
End If
|
||||
Dim ImporteFluctuacion As Decimal = Math.Abs((importeMovimientoDev * difFluctuacion).RoundSQL)
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveVentaDevolucion, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=TipoCambioFactura) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 2) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
'ErrorPrepoliza = True
|
||||
GuardaLogAD($"Ventas/Ventas-ProcesoPrePolizas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{ObjFactura.CvePrePoliza}", "LogPrePolizas")
|
||||
|
||||
'SIRVE PARA VER LA PREPOLIZA QUE SE VALIDA
|
||||
'If ObjConta.GetPrePolizasDetalle(ObjFactura.CvePrePoliza) Then
|
||||
' Dim DtTest = ObjConta.DtResultados
|
||||
'End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
If Not ErrorPrepoliza AndAlso ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 5) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
'ErrorPrepoliza = True
|
||||
GuardaLogAD($"Ventas/Ventas-ProcesoPrePolizas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{ObjFactura.CvePrePoliza}", "LogPrePolizas")
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If ErrorPrepoliza Then
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
'APLICA DEVOLUCION SALDOS DIRECTOS
|
||||
If AplicaDevolucion Then
|
||||
IdCtaContable = ObjFactura.Cliente.IdCtaContClientes
|
||||
Dim IdCtaContableClienteComplementaria As Integer = ObjFactura.Cliente.IdCtaContComplementaria
|
||||
|
||||
Dim importeMovimientoDev = TxtTotal.Text.ToDecimal
|
||||
importeMovimientoDev = If(SaldoVentaDevolucion < importeMovimientoDev, SaldoVentaDevolucion, importeMovimientoDev)
|
||||
If importeMovimientoDev > 0 Then
|
||||
Dim importeMXDev = importeMovimientoDev * tipoCambio * Multiplicador
|
||||
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimientoDev.FormatoNumero(2)}"
|
||||
|
||||
If UsaComplementariaClientes AndAlso tipoCambio > 1 Then
|
||||
importeMXDev = importeMovimientoDev
|
||||
Dim ImporteComplementaria As Decimal = ((importeMovimientoDev * tipoCambio) - importeMovimientoDev).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, importeMovimientoDev, Referencia, 203, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveVentaDevolucion, ImporteMX:=ImporteComplementaria, ImporteME:=If(tipoCambio = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=TipoCambioFactura) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, importeMovimientoDev, Referencia, 91, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveVentaDevolucion, ImporteMX:=importeMXDev, ImporteME:=If(tipoCambio = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If UsaComplementariaClientes AndAlso TipoCambioFactura > 1 Then
|
||||
importeMXDev = importeMovimientoDev
|
||||
Dim ImporteComplementaria As Decimal = ((importeMovimientoDev * TipoCambioFactura) - importeMovimientoDev).RoundSQL
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimientoDev, Referencia, 207, Concepto, FechaMovimiento, IdCtaContableClienteComplementaria, -1, CveVenta:=CveVentaDevolucion, CveCliente:=ObjFactura.CveCliente, ImporteMX:=ImporteComplementaria, ImporteME:=If(TipoCambioFactura = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar, CveVentaAmortizacion:=ObjFactura.CveVenta, TipoCambio:=TipoCambioFactura) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim CveConceptoPagoNC As Integer = 251
|
||||
If ObjFactura.CveMoneda > 1 Then
|
||||
CveConceptoPagoNC = 301
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimientoDev, Referencia, CveConceptoPagoNC, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVentaDevolucion, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteMX:=importeMXDev, ImporteME:=If(tipoCambio = 1, 0, importeMovimientoDev), CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
If tipoCambio <> TipoCambioFactura Then
|
||||
Dim difFluctuacion As Decimal = tipoCambio - TipoCambioFactura
|
||||
Dim CveConceptoFluctua As Integer = 64 '64.ganacia, 65.perdida
|
||||
Dim TipoMovtoFluctua As Boolean = True
|
||||
Dim IdCtaContableFluctua As Integer
|
||||
If difFluctuacion < 0 Then
|
||||
CveConceptoFluctua = 65
|
||||
TipoMovtoFluctua = False
|
||||
Else
|
||||
CveConceptoFluctua = 64
|
||||
TipoMovtoFluctua = True
|
||||
End If
|
||||
Dim ImporteFluctuacion As Decimal = Math.Abs((importeMovimientoDev * difFluctuacion).RoundSQL)
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovtoFluctua, ImporteFluctuacion, Referencia, CveConceptoFluctua, Concepto, FechaMovimiento, IdCtaContableFluctua, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=CveVentaDevolucion, ImporteMX:=ImporteFluctuacion, ImporteME:=ImporteFluctuacion, CveSubProyecto:=CveSubProyectoContabilizar, TipoCambio:=tipoCambio, TipoCambioPago:=TipoCambioFactura) Then
|
||||
ErrorPrepoliza = True
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjConta.ValidacionPrePolizaCuadre(ObjFactura.CvePrePoliza, 2) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
GuardaLogAD($"Ventas/Ventas-ProcesoPrePolizas | Error:{ObjConta.MensajePolizaDescuadre} Diferencia:{ObjConta.ValorDiferencia} | CvePrePoliza:{ObjFactura.CvePrePoliza}", "LogPrePolizas")
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -16576,9 +16408,9 @@ Partial Class Ventas
|
||||
Pago.CveIE = CveIEAnticipo
|
||||
Pago.CveMonedaPago = gvr.DataKey("CveMoneda").ToEntero()
|
||||
Pago.TipoPago = "A"
|
||||
Pago.Fecha = TxtFechaAnticipoCliente.text.todate 'TCPago = gvr.DataKey("TipoCambio").todecimal
|
||||
Pago.Fecha = TxtFechaAnticipoCliente.Text.ToDate 'TCPago = gvr.DataKey("TipoCambio").todecimal
|
||||
Pago.CveVentaAmortizacion = gvr.DataKey("CveVenta").ToEntero()
|
||||
Pago.TCPago = gvr.DataKey("TipoCambio").Todecimal
|
||||
Pago.TCPago = gvr.DataKey("TipoCambio").ToDecimal
|
||||
Pago.AplicaTraslado = gvr.DataKey("RegresarImpuesto") = "1"
|
||||
Pago.Referencia = gvr.DataKey("Folio")
|
||||
|
||||
@@ -21163,12 +20995,8 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
If AutoConta Then
|
||||
If idCuentaContabilizacion > 0 Then
|
||||
If Not ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
||||
Alert("Ocurrio un Error al contabilizar la prepoliza de almacen, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
|
||||
End If
|
||||
Else
|
||||
Alert(String.Format("Falta asignación de las siguientes cuentas contables: {0}", CuentasContablesInvalidas), TipoMensaje.MsgAdvertencia)
|
||||
If Not ObjConta.ContabilizarPrePoliza(ObjFactura.CvePrePoliza, ObjFactura.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then
|
||||
Alert("Ocurrio un Error al contabilizar la prepoliza de almacen, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -34584,6 +34412,18 @@ Partial Class Ventas
|
||||
Else
|
||||
TFuenteRecaudacion.Visible = False
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveRol = 1 Then
|
||||
If ChkEmitirComercioExterior.Checked Then
|
||||
TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate.AddDays(-1)).ToString()
|
||||
Else
|
||||
TxtTipoCambio.Text = GlobalTipoCambio(TxtFecha.Text.ToDate).ToString()
|
||||
End If
|
||||
|
||||
UpPS.Update()
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
'Protected Sub LnkDescargarFacturaPrueba_Click(sender As Object, e As EventArgs)
|
||||
' 'Dim Hilo As New System.Threading.Thread(Sub() DescargarFactura(Me.CveVenta, UsuarioActual.CveEmpresa))
|
||||
@@ -36869,21 +36709,21 @@ Partial Class Ventas
|
||||
DdlTipoActivo_SelectedIndexChanged(DdlTipoActivoFiltro, EventArgs.Empty)
|
||||
End Sub
|
||||
|
||||
Protected Sub CargarTipoActivoFijo()
|
||||
DdlTipoActivoFiltro.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo")
|
||||
DdlTipoActivoFiltro.DataBind()
|
||||
DdlTipoActivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlTipoActivo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
DdlSubTipoActivoFiltro.Items.Clear()
|
||||
DdlSubTipoActivoFiltro.DataSource = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveTipoActivoFijo = {0}", DdlTipoActivoFiltro.SelectedValue), "SubTipoActivoFijo")
|
||||
DdlSubTipoActivoFiltro.DataBind()
|
||||
DdlSubTipoActivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
Protected Sub CargarTipoActivoFijo()
|
||||
DdlTipoActivoFiltro.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros("", "TipoActivoFijo")
|
||||
DdlTipoActivoFiltro.DataBind()
|
||||
DdlTipoActivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlTipoActivo_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
DdlSubTipoActivoFiltro.Items.Clear()
|
||||
DdlSubTipoActivoFiltro.DataSource = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveTipoActivoFijo = {0}", DdlTipoActivoFiltro.SelectedValue), "SubTipoActivoFijo")
|
||||
DdlSubTipoActivoFiltro.DataBind()
|
||||
DdlSubTipoActivoFiltro.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
Protected Sub BtnFiltrarAF_Click(sender As Object, e As EventArgs)
|
||||
Protected Sub BtnFiltrarAF_Click(sender As Object, e As EventArgs)
|
||||
Using ObjAF As New ClsAF
|
||||
If ObjAF.GetRepActivosFijosDepreciacion(UsuarioActual.CveEmpresa, Now, Depreciados:=1, CveTipoAF:=DdlTipoActivoFiltro.SelectedValue.ToEntero(), CveSubTipoAF:=DdlSubTipoActivoFiltro.SelectedValue.ToEntero(), CveSubProyecto:=DdlSubProyectoFiltroAF.SelectedValue.ToEntero()) Then
|
||||
GvVentaAF.DataSource = ObjAF.DtResultados.FiltraParametros("CveActivoFijo > 0 AND CveEstadoActivoFijo <> 5")
|
||||
|
||||
Reference in New Issue
Block a user