-- centralizado de pago de venta en prepolizas

This commit is contained in:
2022-08-15 19:30:49 -07:00
parent bebd233a70
commit aaf5a95b11
2 changed files with 497 additions and 454 deletions

View File

@@ -9388,15 +9388,19 @@ Public Class ClsPaginas
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
Dim tFecha As Date = Pago.Fecha
Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion <= tFecha Then
'FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion
TCValuacion = UltimaFluctuacion.TCFluctuacion
If CompraActual.CveMoneda <> 1 OrElse Pago.CveMonedaPago <> 1 Then
Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion <= tFecha Then
'FechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion
TCValuacion = UltimaFluctuacion.TCFluctuacion
End If
End If
End If
If CompraActual.CveMoneda = 1 And Pago.CveMonedaPago <> 1 Then 'factura pesos, pago en dolares
tImportePago = ((Pago.ImportePago * TCValuacion / Pago.TCPago).RoundSQL * Pago.TCPago).RoundSQL
ElseIf CompraActual.CveMoneda <> 1 And Pago.CveMonedaPago <> 1 Then 'factura dolares, pago en dolares
@@ -9425,7 +9429,7 @@ Public Class ClsPaginas
ImporteMN = (ImporteMovimiento * CompraActual.TC).RoundSQL
If CompraActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
Dim Ret As CompraRetenciones = CompraActual.ConceptoPrePolizaIVA
Dim Ret As ConceptosRetenciones = CompraActual.ConceptoPrePolizaIVA
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteMovimiento, ImporteMN, Ret.CveConceptoxAcreditar, CompraActual.SerieFolio, Concepto, Ret.IdCtaContablexAcreditar, CveCompra:=CompraActual.CveCompra, CveProveedor:=CompraActual.CveProveedor, CveIE:=Pago.CveIE, PorcentajeImpuesto:=CompraActual.PorcentajeIVA, CvePersonal:=Pago.CvePersonal, TipoCambio:=CompraActual.TC, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
@@ -9451,7 +9455,7 @@ Public Class ClsPaginas
ImporteMN = (ImporteMovimiento * CompraActual.TC).RoundSQL
If CompraActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
Dim Ret As CompraRetenciones = CompraActual.ConceptoPrePolizaRetIVA
Dim Ret As ConceptosRetenciones = CompraActual.ConceptoPrePolizaRetIVA
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, Ret.CveConceptoxAcreditar, CompraActual.SerieFolio, Concepto, Ret.IdCtaContablexAcreditar, CveCompra:=CompraActual.CveCompra, CveProveedor:=CompraActual.CveProveedor, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
@@ -9467,7 +9471,7 @@ Public Class ClsPaginas
ImporteMN = (ImporteMovimiento * CompraActual.TC).RoundSQL
If CompraActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
Dim Ret As CompraRetenciones = CompraActual.ConceptoPrePolizaRetISR
Dim Ret As ConceptosRetenciones = CompraActual.ConceptoPrePolizaRetISR
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, Ret.CveConceptoxAcreditar, CompraActual.SerieFolio, Concepto, Ret.IdCtaContablexAcreditar, CveCompra:=CompraActual.CveCompra, CveProveedor:=CompraActual.CveProveedor, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
'si tiene funcionalidad para tomar el TC de pago. se recalcula el importe
@@ -9483,7 +9487,7 @@ Public Class ClsPaginas
ImporteMN = (ImporteMovimiento * CompraActual.TC).RoundSQL
If CompraActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
Dim Ret As New CompraRetenciones
Dim Ret As New ConceptosRetenciones
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
If ObjConta.GetRetCuenta(26, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
@@ -9590,9 +9594,9 @@ Public Class ClsPaginas
Public Property IdCtaContableProv As Integer
Public Property IdCtaContableProvComplementaria As Integer
Public ReadOnly Property ConceptoPrePolizaIVA As CompraRetenciones
Public ReadOnly Property ConceptoPrePolizaIVA As ConceptosRetenciones
Get
Dim Ret As New CompraRetenciones
Dim Ret As New ConceptosRetenciones
If EsImportacion Then
Ret.CveConceptoAcreditable = 288
Ret.CveConceptoxAcreditar = 287
@@ -9618,9 +9622,9 @@ Public Class ClsPaginas
End Get
End Property
Public ReadOnly Property ConceptoPrePolizaRetIVA As CompraRetenciones
Public ReadOnly Property ConceptoPrePolizaRetIVA As ConceptosRetenciones
Get
Dim Ret As New CompraRetenciones
Dim Ret As New ConceptosRetenciones
Dim Funcionalidad As Integer
If CveConceptoRetIVA = 1 Then
Funcionalidad = 308
@@ -9670,9 +9674,9 @@ Public Class ClsPaginas
Return Ret
End Get
End Property
Public ReadOnly Property ConceptoPrePolizaRetISR As CompraRetenciones
Public ReadOnly Property ConceptoPrePolizaRetISR As ConceptosRetenciones
Get
Dim Ret As New CompraRetenciones
Dim Ret As New ConceptosRetenciones
Dim Funcionalidad As Integer
If CveConceptoRetISR = 1 Then
Funcionalidad = 316
@@ -9714,7 +9718,7 @@ Public Class ClsPaginas
End Class
Public Class CompraRetenciones
Public Class ConceptosRetenciones
Public Property CveConceptoxAcreditar As Integer
Public Property CveConceptoAcreditable As Integer
Public Property IdCtaContablexAcreditar As Integer
@@ -9727,5 +9731,290 @@ 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
Dim ErrorMovtos As Boolean = False
Dim PorcentajePago As Decimal = Pago.ImportePago / VentaActual.Total
Dim ImporteMovimiento As Decimal = 0
Dim ImporteMN As Decimal = 0
Dim ImporteME As Decimal = 0
Dim TCValuacion As Decimal
Dim TCValuacionVenta As Decimal = VentaActual.TC
Dim TCValuacionPago As Decimal = Pago.TCPago
Dim tFechaUltimaFluctuacion As Date
Dim tImportePago, tImporteVenta As Decimal
Dim CveConceptoContableComplementaria As Integer = 207
Pago.CveConceptoPago = If(Pago.CveConceptoPago = -1, 2, Pago.CveConceptoPago) 'si viene en parametro lo toma com primera opcion, sino el 2
If VentaActual.CveMoneda <> 1 Then Pago.CveConceptoPago = 292
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 tFecha As Date = Pago.Fecha
Dim UltimaFluctuacion As MTipoCambioFluctuacion = GlobalTipoCambioUltimaFluctuacion(tFecha)
If UsuarioActual.Empresa.Funcionalidad(703) = "1" AndAlso UltimaFluctuacion IsNot Nothing Then
If UltimaFluctuacion.FechaFluctuacion <= tFecha Then
tFechaUltimaFluctuacion = UltimaFluctuacion.FechaFluctuacion
TCValuacion = UltimaFluctuacion.TCFluctuacion
End If
If VentaActual.Fecha < tFechaUltimaFluctuacion Then TCValuacionVenta = TCValuacion
If Pago.FechaDocumentoRelacionado < tFechaUltimaFluctuacion Then TCValuacionPago = TCValuacion
End If
If VentaActual.CveMoneda = 1 And Pago.CveMonedaPago <> 1 Then 'factura pesos, pago en dolares
tImportePago = ((Pago.ImportePago * TCValuacionVenta / Pago.TCPago).RoundSQL * Pago.TCPago).RoundSQL
ElseIf VentaActual.CveMoneda <> 1 And Pago.CveMonedaPago <> 1 Then 'factura dolares, pago en dolares
tImporteVenta = (Pago.ImportePago * TCValuacionVenta).RoundSQL
tImportePago = (Pago.ImportePago * TCValuacionPago).RoundSQL
ElseIf VentaActual.CveMoneda <> 1 And Pago.CveMonedaPago = 1 Then 'factura dolares, pago en pesos
tImporteVenta = (Pago.ImportePago * TCValuacionVenta).RoundSQL
tImportePago = (Pago.ImportePago * TCValuacionPago).RoundSQL
End If
If VentaActual.CveMoneda > 1 Then ImporteME = Pago.ImportePagoVenta
'movimiento de pago cliente
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, Pago.ImportePagoVenta, Pago.CveConceptoPago, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableCliente, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacion, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
'movimiento de pago cliente Complementaria
If Not ErrorMovtos AndAlso VentaActual.CveMoneda > 1 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePagoVenta, (ImporteME * TCValuacion - ImporteME).RoundSQL, CveConceptoContableComplementaria, VentaActual.SerieFolio, Concepto, VentaActual.IdCtaContableClienteComplementaria, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveVentaAmortizacion:=Pago.CveVentaAmortizacion, TipoCambio:=TCValuacion, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
End If
If Pago.AplicaTraslado Then
'si tiene iva y su proporcion
If Not ErrorMovtos AndAlso VentaActual.IVA <> 0 Then
ImporteMovimiento = (PorcentajePago * VentaActual.IVA).RoundSQL
ImporteMN = (ImporteMovimiento * VentaActual.TC).RoundSQL
If VentaActual.CveMoneda > 1 Then ImporteME = ImporteMovimiento
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteMovimiento, ImporteMN, 13, 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) 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, 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) 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, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) 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, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) 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, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) 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, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) 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.IdCtaContableAcreditable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSAcreditable").ToString.ToEntero
If ObjConta.GetRetCuenta(39, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then Ret.IdCtaContablexAcreditar = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxAcreditar").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, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) 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, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
End If
If Pago.TipoPago = "A" AndAlso Not ErrorMovtos Then 'A N T I C I P O
Dim Ret As New ConceptosRetenciones
If Pago.CveMonedaPago > 1 Then
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 11, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteAnticipo, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True
ImporteMN = (Pago.ImportePago * TCValuacionPago - Pago.ImportePago).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, ImporteMN, 207, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteAnticipoComplementaria, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True
Else
'Agregamos Nacional
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 11, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteAnticipoExtranjera, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, TipoCambioPago:=Pago.TCPago) Then ErrorMovtos = True
End If
End If
If Pago.TipoPago = "NC" AndAlso Not ErrorMovtos Then ' N O T A D E C R E D I T O
Dim Ret As New ConceptosRetenciones
If Pago.CveMonedaPago > 1 Then
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 91, Pago.Referencia, Concepto, VentaActual.IdCtaContableCliente, CveVenta:=Pago.CveVentaAmortizacion, CveVentaAmortizacion:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True
ImporteMN = (Pago.ImportePago * TCValuacionPago - Pago.ImportePago).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, ImporteMN, 203, Pago.Referencia, Concepto, VentaActual.IdCtaContableClienteComplementaria, CveVenta:=Pago.CveVentaAmortizacion, CveVentaAmortizacion:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto) Then ErrorMovtos = True
Else
'Agregamos Nacional
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, Pago.ImportePago, 91, Pago.Referencia, Concepto, VentaActual.IdCtaContableCliente, CveVenta:=Pago.CveVentaAmortizacion, CveVentaAmortizacion:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True
End If
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 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
End If
If Pago.CveMonedaPago > 1 Then
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 66, Pago.Referencia, Concepto, Ret.IdCtaContableAcreditable, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True
ImporteMN = (Pago.ImportePago * TCValuacionPago - Pago.ImportePago).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, ImporteMN, 207, Pago.Referencia, Concepto, Ret.IdCtaContablexAcreditar, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, ImporteME:=Pago.ImportePago, TipoCambio:=TCValuacionPago, CveSubProyecto:=VentaActual.CveSubProyecto, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True
Else
'Agregamos Nacional
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 66, Pago.Referencia, Concepto, Ret.IdCtaContableAcreditable, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CveSubProyecto:=VentaActual.CveSubProyecto, CvePersonal:=Pago.CvePersonal) Then ErrorMovtos = True
End If
End If
'si tiene otros gastos/ingresos
ImporteMovimiento = Pago.OtroGastoIngreso
If Not ErrorMovtos AndAlso ImporteMovimiento <> 0 Then
Dim tOtCveCon As Integer = 211
Dim tOtTipoMovto As Boolean = False
If ImporteMovimiento < 0 Then
tOtTipoMovto = True : tOtCveCon = 78
ImporteMovimiento = Math.Abs(ImporteMovimiento)
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, tOtTipoMovto, ImporteMovimiento, ImporteMovimiento, tOtCveCon, VentaActual.SerieFolio, Concepto, 0, CveVenta:=VentaActual.CveVenta, CveCliente:=VentaActual.CveCliente, CveIE:=Pago.CveIE, CvePersonal:=Pago.CvePersonal, CveSubProyecto:=VentaActual.CveSubProyecto, TipoCambioPago:=Pago.TCPago, ImporteME:=ImporteME) Then ErrorMovtos = True
End If
If Not ErrorMovtos AndAlso VentaActual.TC <> Pago.TCPago Then
Dim ConceptoContable, IdCtaContable As Integer
Dim TipoMovimiento As Boolean
Dim Diferencia As Decimal = 0
If tImporteVenta <> tImportePago Then
If tImporteVenta > tImportePago Then
ConceptoContable = 64 : IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
TipoMovimiento = True
Else
ConceptoContable = 65 : IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
TipoMovimiento = False
End If
Diferencia = (tImporteVenta - tImportePago).Abs.RoundSQL
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
Diferencia -= ((VentaActual.IVA * PorcentajePago) * VentaActual.TC) - ((VentaActual.IVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el IVA
Diferencia += ((VentaActual.RetIVA * PorcentajePago) * VentaActual.TC) - ((VentaActual.RetIVA * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetIVA
Diferencia += ((VentaActual.RetISR * PorcentajePago) * VentaActual.TC) - ((VentaActual.RetISR * PorcentajePago) * TCImpuestos) 'Añadimos la diferencia de ganancia en el RetISR
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
End If
End If
End If
Return ErrorMovtos
End Function
Public Class VentaPago
Public Property TipoPago As String = "B" ' B - Bancos, A - Anticipos, I - IxC, NC - Nota de crédito
Public FechaDocumentoRelacionado As Date
Public Fecha As Date
Public Property CveIE As Integer = -1
Public Property CvePersonal As Integer = -1
Public Property ImportePagoVenta As Decimal = 0
Public Property ImportePago As Decimal = 0
Public Property CveMonedaPago As Integer = 1
Public Property TCPago As Decimal = 1
Public Property CveVentaAmortizacion As Integer = 0
Public Property OtroGastoIngreso As Decimal = 0
Public Property CveConceptoPago As Integer = -1 'no definido de inicio
Public Property CveCreditoDetalle As Integer = -1
Public Property AplicaTraslado As Boolean = True
Public Property Referencia As String
End Class
Public Class Venta
Public Property CveVenta As Integer = -1
Public Property CveCliente As Integer
Public Property CveMoneda As Integer
Public Property Fecha As Date
Public Property SerieFolio As String = ""
Public Property ClienteNombre As String = ""
Public Property TC As Decimal = 1
Public Property Total As Decimal
Public Property IVA As Decimal
Public Property IEPS As Decimal
Public Property RetIVA As Decimal
Public Property RetISR As Decimal
Public Property PorcentajeIVA As Decimal
Public Property CveSubProyecto As Integer
Public Property UsuarioActual As Usuario
Public Property IdCtaContableCliente As Integer
Public Property IdCtaContableClienteComplementaria As Integer
Public Property IdCtaContableClienteAnticipo As Integer
Public Property IdCtaContableClienteAnticipoExtranjera As Integer
Public Property IdCtaContableClienteAnticipoComplementaria As Integer
End Class
#End Region
End Class

View File

@@ -1388,6 +1388,15 @@ Partial Class Ventas
End Set
End Property
Private Property VentaActual As Venta
Get
Return DirectCast(ViewState("VentaActual"), Venta)
End Get
Set(value As Venta)
ViewState("VentaActual") = value
End Set
End Property
Private Property ListaAnticiposAplicados As List(Of MAnticipoRelacionado)
Get
Return If(IsNothing(ViewState("ListaAnticiposAplicados")), Nothing, CType(ViewState("ListaAnticiposAplicados"), List(Of MAnticipoRelacionado)))
@@ -5055,6 +5064,30 @@ Partial Class Ventas
TxtPedidoContrato.Enabled = False
TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString().PadLeft(6, "0"c)
VentaActual = New Venta
VentaActual.CveVenta = CveVenta
VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero
VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
VentaActual.SerieFolio = DbRowVenta("SerieFolio").ToString
VentaActual.ClienteNombre = DbRowVenta("ClienteNombre").ToString
VentaActual.TC = DbRowVenta("TipoCambio").ToString.ToDecimal
VentaActual.Total = DbRowVenta("Total").ToString.ToDecimal
VentaActual.IVA = DbRowVenta("IVA").ToString.ToDecimal
VentaActual.IEPS = DbRowVenta("IEPS").ToString.ToDecimal
VentaActual.RetIVA = DbRowVenta("RetIVA").ToString.ToDecimal
VentaActual.RetISR = DbRowVenta("RetISR").ToString.ToDecimal
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
VentaActual.UsuarioActual = UsuarioActual
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
VentaActual.IdCtaContableCliente = IIf(VentaActual.CveMoneda = 1, ViewState("IdCtaContClientes"), ViewState("IdCtaContMonedaExtranjera")).ToString.ToEntero
VentaActual.IdCtaContableClienteComplementaria = ViewState("IdCtaContComplementaria").ToString.ToEntero
VentaActual.IdCtaContableClienteAnticipo = ViewState("IdCtaContAnticipos").ToString.ToEntero
VentaActual.IdCtaContableClienteAnticipoExtranjera = ViewState("IdCtaContAnticiposExtranjera").ToString.ToEntero
VentaActual.IdCtaContableClienteAnticipoComplementaria = ViewState("IdCtaContAnticiposComplementaria").ToString.ToEntero
HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString()
HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2)
'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString()
@@ -15496,14 +15529,14 @@ Partial Class Ventas
Dim ErrorConta As Boolean
Dim CveIEAnticipo As Integer
Dim CvePlantillaPoliza As Integer = 10
Dim PorcentajeAmortizacion As Decimal
Dim sumaAmorticaciones As Decimal = 0
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
Dim CveCuentaContabilizacion As Integer = 1
'Dim PorcentajeAmortizacion As Decimal
'Dim sumaAmorticaciones As Decimal = 0
'Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
'Dim CveCuentaContabilizacion As Integer = 1
Dim CuentasContablesInvalidas As New StringBuilder
Dim ContaIdPoliza As Integer = 0
Dim ConceptoAmortizacion As Integer = 0
Dim UsaComplementariaClientes As Boolean = True
'Dim ConceptoAmortizacion As Integer = 0
'Dim UsaComplementariaClientes As Boolean = True
Dim SimplificaPrePoliza As Boolean = True
''[IPP] PARCHE TEMPORAL PARA ANTICIPOS DE JAM
@@ -15532,11 +15565,6 @@ Partial Class Ventas
Dim Importe91 As Decimal = 0
If GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("PorcentajeIVA").ToDouble).Rows.Count > 0 Then
Dim Dr As DataRow = GlobalDTClasificacionPorcentaje(UsuarioActual.CveEmpresa, PorcentajeIVA:=TmpDT.MAX("PorcentajeIVA").ToDouble).FiltroPrimero("")
IdCtaIVAXTrasladar = Dr("IdCtaIVAXTrasladar").ToString().ToEntero()
IdCtaIVATrasladado = Dr("IdCtaIVATrasladado").ToString().ToEntero()
End If
For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then
@@ -15557,7 +15585,6 @@ Partial Class Ventas
End If
If DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 1 Then 'SI LA VENTA VIENE EN PESOS Y SE VA A PAGAR EN PESOS
tipoCambioPago = 1
tipoCambioVenta = 1
@@ -15580,440 +15607,167 @@ Partial Class Ventas
PorcentajePago = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal) / gvr.DataKey("Original").ToDecimal
End If
If dtConceptos IsNot Nothing Then
For Each Row As DataRow In dtConceptos.Rows
Dim importeMovimiento As Decimal = 0
Dim importeMN As Decimal = 0
Dim TC As Decimal
Dim IdCtaContable As Integer
Dim TipoMovimiento As Boolean = True
Dim Concepto As String = VentaActual.SerieFolio
Dim Referencia As String = VentaActual.SerieFolio
Dim ConceptoContable = Row("CveConcepto").ToString().ToEntero()
Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString() = "True", True, False)
Dim importeMovimiento As Decimal = 0
Dim importeMX As Decimal = 0
Dim IdCtaContable As Integer = 0
Dim FechaMovimiento As Date = Now
Dim Concepto As String = ViewState("VentaFolio").ToString()
Dim Referencia As String = ViewState("VentaFolio").ToString()
Dim FuncionalidadFluctuacionImpuestos As Boolean = If(UsuarioActual.Empresa.Funcionalidad(159) = "1", True, False)
Dim TipoCambioGeneral As Decimal = 1
Dim PorcentajeImpuesto As Decimal = 0
Select Case gvr.DataKey("CveConceptoContable").ToString()
Case "3"
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
Select Case ConceptoContable
Case 2 'Cliente
'If CveMonedaVenta > 1 Then ConceptoContable = 292
If Not (gvr.DataKey("CveIE").ToString().ToEntero() > 0 AndAlso gvr.DataKey("CveConceptoContable").ToString().ToEntero() = 66) Then
If DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento
ElseIf DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVentaValuacion
ElseIf DdlMoneda.SelectedValue.ToEntero() = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVentaValuacion
ElseIf DdlMoneda.SelectedValue.ToEntero() = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero() = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento
End If
importeMovimiento = importeMovimiento.RoundSQL
importeMX = importeMX.RoundSQL
TipoCambioGeneral = tipoCambioVentaValuacion
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("TotalAnticipo").ToDecimal) * gvr.DataKey("IVAAnticipo").ToDecimal)
If CveMonedaVenta = 1 Then
IdCtaContable = IdCtaContClientes
'CveCuenta = CveCuentaClientes
Else
IdCtaContable = IdCtaContComplementaria
If importeMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsaComplementariaClientes) Then
'Conta ContPAQ
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(CvePrePoliza, TipoMovimiento, 0, Concepto, 207, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta - importeMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, TipoCambio:=tipoCambioVentaValuacion, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
importeMX = importeMovimiento
IdCtaContable = IdCtaContMonedaExtranjera
End If
End If
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
ConceptoContable = 251 ' cambia para dejar el concepto 2, solamente para pago en banco
End If
Case 11 'Anticipo
If gvr.DataKey("CveConceptoContable").ToString().ToEntero() = 3 Then
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("TotalAnticipo").ToDecimal) * gvr.DataKey("IVAAnticipo").ToDecimal)
'Mantenemos la integridad de la suma para el pagocliente
'SumaAnticipos += row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal
'sumaAmorticaciones += row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal
TipoCambioGeneral = tipoCambioPago
IdCtaContable = IdCtaContAnticipos
If importeMovimiento <> 0 Then
'Conta ContPAQ
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(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=gvr.DataKey("CveVenta").ToEntero(), CveVentaAmortizacion:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento * tipoCambioPago, ImporteME:=If(tipoCambioPago = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
' PorcentajeAmortizacion = SumaAnticipos / TxtTotal.Text.ToDecimal
'Los Anticipos solo ocupan los ivas por trasladar
If PorcentajePago > 0 Then
Dim Importe13 = gvr.DataKey("IVA").ToDecimal
Dim Importe8 = gvr.DataKey("RetIVA").ToDecimal
Dim Importe9 = gvr.DataKey("RetISR").ToDecimal
If Not AgregarPrePolizasXTrasladar(ObjConta, CvePrePoliza, PorcentajePago, tipoCambioPago, CuentasContablesInvalidas, idCuentaContabilizacion, CveCuentaContabilizacion, Importe13, Importe8, Importe9) Then
ErrorConta = True
End If
End If
End If
importeMovimiento = 0
Case 91 'Amortizacion Nota de Credito
Dim TC As Decimal = 1
If gvr.DataKey("CveConceptoContable").ToEntero() = 12 Then
If CveMonedaVenta = 1 And gvr.DataKey("CveMoneda").ToEntero = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento
TC = gvr.DataKey("TipoCambio").ToString().ToDecimal
ElseIf CveMonedaVenta = 2 And gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento * gvr.DataKey("TipoCambio").ToString().ToDecimal
TC = gvr.DataKey("TipoCambio").ToString().ToDecimal
ElseIf CveMonedaVenta = 1 And gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento * gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
TC = TipoCambioFluctuacion
ElseIf CveMonedaVenta = 2 And gvr.DataKey("CveMoneda").ToEntero = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento
TC = gvr.DataKey("TipoCambio").ToString().ToDecimal
End If
importeMovimiento = importeMovimiento.RoundSQL
importeMX = importeMX.RoundSQL
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(ConceptoContable, CveCliente) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString().ToEntero()
End If
End If
If importeMovimiento <> 0 Then
'Conta ContPAQ
If IdCtaContable <= 0 Then
CuentasContablesInvalidas.Append("<br>" & GlobalDTContaConceptosContables(-1).FiltroPrimero(String.Format("CveConceptoContable = {0}", ConceptoContable))("ConceptoContable").ToString())
idCuentaContabilizacion = 0
End If
Dim ImporteComplementaria As Decimal = 0
If UsaComplementariaClientes = True AndAlso gvr.DataKey("CveMoneda").ToString().ToDecimal > 1 Then
IdCtaContable = IdCtaContComplementaria
importeMX = importeMovimiento
ImporteComplementaria = ((importeMovimiento * TC) - importeMovimiento).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Concepto, 203, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=gvr.DataKey("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, ImporteMX:=ImporteComplementaria, ImporteME:=If(gvr.DataKey("TipoCambio").ToString().ToDecimal = 1, 0, importeMovimiento), TipoCambio:=TC, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
Exit For
End If
IdCtaContable = IdCtaContMonedaExtranjera
End If
If CveMonedaVenta > 1 AndAlso IdCtaContMonedaExtranjera > 0 Then
IdCtaContable = IdCtaContMonedaExtranjera
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=gvr.DataKey("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, ImporteMX:=importeMX, TipoCambio:=TC, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
Exit For
End If
'AMORTIZA NC CONTRA ANTICIPO A CLIENTES
If Not ErrorConta And DdlTipoComprobante.SelectedValue = "Ant" Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("Original").ToDecimal) * gvr.DataKey("IVA").ToDecimal)
If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Concepto, 11, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveVentaAmortizacion:=gvr.DataKey("CveVenta").ToString().ToEntero(), ImporteMX:=importeMovimiento) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Concepto, 4, Concepto, FechaMovimiento, gvr.DataKey("IdCtaContableNC").ToEntero(), -1, CveClasificacion:=gvr.DataKey("CveClasificacionNC").ToEntero(), CveVenta:=gvr.DataKey("CveVenta").ToString().ToEntero(), CveCliente:=CveCliente, CveVentaAmortizacion:=CveVenta, ImporteMX:=importeMovimiento * TC, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
Exit For
End If
Else
ErrorConta = True
Exit For
End If
End If
End If
End If
Importe91 = importeMovimiento
importeMovimiento = 0
Case 92 'Amortizacion Ingreso X Comprobar
If gvr.DataKey("CveIE").ToEntero() > 0 AndAlso gvr.DataKey("CveConceptoContable").ToEntero() = 66 Then
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
IdCtaContable = IdCtaContClientes
If importeMovimiento <> 0 Then
' Agregamos el 2
If tipoCambioPago = 1 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 2, Concepto, FechaMovimiento, IdCtaContClientes, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
Else 'Cuando son dolares
If importeMovimiento <> 0 Then
If IdCtaContComplementaria > 0 Or 0 > 0 Then
'Agregamos la Complementaria
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, 0, Concepto, 207, Concepto, FechaMovimiento, IdCtaContComplementaria, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta - importeMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, CveCuenta:=0, TipoCambio:=tipoCambioVenta, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 2, Concepto, FechaMovimiento, IdCtaContMonedaExtranjera, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=0, TipoCambio:=tipoCambioVenta, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
Else
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 2, Concepto, FechaMovimiento, IdCtaContMonedaExtranjera, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, CveCuenta:=0, TipoCambio:=tipoCambioVenta, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
End If
End If
importeMovimiento = ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / TxtTotal.Text.ToDecimal) * TxtIVA.Text.ToDecimal)
importeMX = Math.Round(importeMovimiento * tipoCambioPago, 2, MidpointRounding.AwayFromZero)
If importeMX <> 0 Then
'Agregamos el 13
IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, 13, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMX, TipoCambio:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuestoAmortizacion, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
'Agregamos el 61
IdCtaContable = If(IdCtaIVATrasladado > 0, IdCtaIVATrasladado, UsuarioActual.Empresa.IdCuentaIVATrasladado)
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 61, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMX, TipoCambio:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuestoAmortizacion, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
'IEPS
importeMovimiento = ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / TxtTotal.Text.ToDecimal) * TxtIEPS.Text.ToDecimal)
importeMX = Math.Round(importeMovimiento * tipoCambioPago, 2, MidpointRounding.AwayFromZero)
If importeMX <> 0 Then
'Agregamos el 38
IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSxTrasladar
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, 38, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMX, TipoCambio:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuestoAmortizacion, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
'Agregamos el 39
IdCtaContable = UsuarioActual.Empresa.IdCuentaIEPSTrasladado
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 61, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMX, TipoCambio:=tipoCambioPago, PorcentajeImpuesto:=PorcentajeImpuestoAmortizacion, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
'Agregamos el 92
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal 'gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("TotalAnticipo" & gvr.RowIndex).ToDecimal) * gvr.DataKey("IVAAnticipo").ToDecimal)
importeMX = Math.Round(importeMovimiento * tipoCambioPago, 2, MidpointRounding.AwayFromZero)
IdCtaContable = IdCtaContAnticipos
If ObjCliente.GetClientes(gvr.DataKey("CveCliente").ToEntero(), "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
If Not tipoCambioPago = 1 Then
IdCtaContable = ObjCliente.IdCtaMonedaExtranjeraAnticipos
Else
IdCtaContable = ObjCliente.IdCtaContAnticipos
End If
End If
End If
If UsuarioActual.CveEmpresa.Contiene(119) Then
If gvr.DataKey("Fecha").ToDate.Year <= 2017 AndAlso TxtFechaAnticipoCliente.Text.ToDate.Year >= 2018 Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
If Not tipoCambioPago = 1 Then
IdCtaContable = ObjCliente.IdCtaContMonedaExtranjera
Else
IdCtaContable = ObjCliente.IdCtaContClientes
End If
End If
End If
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMX, CveCuenta:=-1, TipoCambio:=tipoCambioPago, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
End If
importeMovimiento = 0
Case 64 'Ganancia
If CveMonedaVenta <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero() <> 1 Then
IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
If CveMonedaVenta = 1 And gvr.DataKey("CveMoneda").ToString().ToDecimal = 2 Then
If tipoCambioVentaValuacion > tipoCambioPago AndAlso gvr.DataKey("CveMoneda").ToEntero() = 2 Then
importeMovimiento = Importe91 * (tipoCambioVentaValuacion - tipoCambioPago) 'Añadimos la diferencia de ganancia en la venta
importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2))
importeMX = importeMovimiento
End If
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioVentaValuacion, tipoCambioPago)
TipoCambioGeneral = TCImpuestos
Else
Dim TipoCambioGanancia As Decimal = If(Not (gvr.DataKey("CveIE").ToEntero() > 0 AndAlso gvr.DataKey("CveConceptoContable").ToString().ToEntero() = 66), tipoCambioVentaValuacion, tipoCambioVenta)
If tipoCambioPago > TipoCambioGanancia AndAlso gvr.DataKey("CveMoneda").ToEntero() = 2 Then
importeMovimiento = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioPago) - (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * TipoCambioGanancia) 'Añadimos la diferencia de ganancia en la venta
importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2))
importeMX = importeMovimiento
End If
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioGanancia, tipoCambioPago)
TipoCambioGeneral = TCImpuestos
End If
Else
importeMovimiento = 0
End If
Case 65 'Perdida
If CveMonedaVenta <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero() <> 1 Then
IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
If CveMonedaVenta = 1 And gvr.DataKey("CveMoneda").ToString().ToDecimal = 2 Then
If tipoCambioVentaValuacion < tipoCambioPago AndAlso gvr.DataKey("CveMoneda").ToEntero() = 2 Then
importeMovimiento = Importe91 * Math.Abs(tipoCambioVentaValuacion - tipoCambioPago) 'Añadimos la diferencia de ganancia en la venta
importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2))
importeMX = importeMovimiento
End If
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioVentaValuacion, tipoCambioPago)
TipoCambioGeneral = TCImpuestos
Else
Dim TipoCambioPerdida As Decimal = If(Not (gvr.DataKey("CveIE").ToEntero() > 0 AndAlso gvr.DataKey("CveConceptoContable").ToString().ToEntero() = 66), tipoCambioVentaValuacion, tipoCambioVenta)
If tipoCambioPago < TipoCambioPerdida AndAlso gvr.DataKey("CveMoneda").ToEntero() = 2 Then
importeMovimiento = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * TipoCambioPerdida) - (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2))
importeMX = importeMovimiento
End If
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPerdida, tipoCambioPago)
TipoCambioGeneral = TCImpuestos
End If
Else
importeMovimiento = 0
End If
Case 13 ' IVA x Trasladar
If gvr.DataKey("RegresarImpuesto") = "1" Then
''gvr.DataKey("DevolucionImportePagado"), de aqui se toma que % de pago tenia la DEV
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * gvr.DataKey("DevolucionImportePagado").ToDecimal
PorcentajeImpuesto = TmpDT.MAX("PorcentajeIVA").ToDecimal '(importeMovimiento / TxtTotal.Text.ToDecimal()) 'falta TC
importeMovimiento = (TxtIVA.Text.ToDecimal * (importeMovimiento / TxtTotal.Text.ToDecimal())).RoundSQL
importeMX = importeMovimiento
IdCtaContable = IdCtaIVAXTrasladar
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 13, NombreCliente, VentaFolio, "")
'If importeMovimiento <> 0 Then
' IdCtaContable = If(IdCtaIVAXTrasladar > 0, IdCtaIVAXTrasladar, UsuarioActual.Empresa.IdCuentaIVAxTrasladar)
'End If
Else
importeMovimiento = 0
PorcentajeImpuesto = 0
End If
Case 61 ' IVA Trasladado
If gvr.DataKey("RegresarImpuesto") = "1" Then
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * gvr.DataKey("DevolucionImportePagado").ToDecimal
PorcentajeImpuesto = TmpDT.MAX("PorcentajeIVA").ToDecimal
importeMovimiento = (TxtIVA.Text.ToDecimal * (importeMovimiento / TxtTotal.Text.ToDecimal())).RoundSQL
importeMX = importeMovimiento
IdCtaContable = IdCtaIVATrasladado
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 61, NombreCliente, VentaFolio, "")
Else
importeMovimiento = 0
PorcentajeImpuesto = 0
End If
Case 38 ' IEPS x Trasladar
If gvr.DataKey("RegresarImpuesto") = "1" Then
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * gvr.DataKey("DevolucionImportePagado").ToDecimal
PorcentajeImpuesto = 0 '(importeMovimiento / TxtTotal.Text.ToDecimal()) 'falta TC
importeMovimiento = (TxtIEPS.Text.ToDecimal * (importeMovimiento / TxtTotal.Text.ToDecimal())).RoundSQL
importeMX = importeMovimiento
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSxTrasladar").ToString().ToEntero()
End If
End If
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 38, NombreCliente, VentaFolio, "")
Else
importeMovimiento = 0
PorcentajeImpuesto = 0
End If
Case 39 ' IEPS Trasladado
If gvr.DataKey("RegresarImpuesto") = "1" Then
SimplificaPrePoliza = False
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * gvr.DataKey("DevolucionImportePagado").ToDecimal
PorcentajeImpuesto = 0
importeMovimiento = (TxtIEPS.Text.ToDecimal * (importeMovimiento / TxtTotal.Text.ToDecimal())).RoundSQL
importeMX = importeMovimiento
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso importeMovimiento <> 0 AndAlso ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaIEPSTrasladado").ToString().ToEntero()
End If
End If
Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 39, NombreCliente, VentaFolio, "")
Else
importeMovimiento = 0
PorcentajeImpuesto = 0
End If
Case Else
importeMovimiento = 0
PorcentajeImpuesto = 0
importeMX = 0
End Select
' TipoCambioGeneral = tipoCambioPago
' IdCtaContable = IdCtaContAnticipos
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(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1,
CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=importeMX, TipoCambio:=TipoCambioGeneral, CveIE:=CveIEAnticipo,
PorcentajeImpuesto:=PorcentajeImpuesto, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
Exit For
Dim Pago As New VentaPago
Pago.ImportePagoVenta = importeMovimiento
Pago.ImportePago = importeMovimiento
Pago.CveIE = CveIEAnticipo
Pago.CveMonedaPago = gvr.DataKey("CveMoneda").ToEntero()
Pago.TipoPago = "A"
Pago.CveVentaAmortizacion = gvr.DataKey("CveVenta").ToEntero()
Pago.AplicaTraslado = gvr.DataKey("RegresarImpuesto") = "1"
Pago.Referencia = gvr.DataKey("Folio")
ErrorConta = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta)
End If
Case "12"
If CveMonedaVenta = 1 And gvr.DataKey("CveMoneda").ToEntero = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMN = importeMovimiento
TC = gvr.DataKey("TipoCambio").ToString().ToDecimal
ElseIf CveMonedaVenta = 2 And gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMN = importeMovimiento * gvr.DataKey("TipoCambio").ToString().ToDecimal
TC = gvr.DataKey("TipoCambio").ToString().ToDecimal
ElseIf CveMonedaVenta = 1 And gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
importeMN = importeMovimiento * gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
TC = TipoCambioFluctuacion
ElseIf CveMonedaVenta = 2 And gvr.DataKey("CveMoneda").ToEntero = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
importeMN = importeMovimiento
TC = gvr.DataKey("TipoCambio").ToString().ToDecimal
End If
importeMovimiento = importeMovimiento.RoundSQL
importeMN = importeMN.RoundSQL
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso ObjConta.GetRetCuenta(12, CveCliente) Then
If ObjConta.DtResultados.Rows.Count > 0 Then
IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString().ToEntero()
End If
End If
Next
End If
If importeMovimiento <> 0 Then
Dim Pago As New VentaPago
Pago.Fecha = TxtFechaAnticipoCliente.Text.ToDate
Pago.FechaDocumentoRelacionado = gvr.DataKey("Fecha").ToDate
Pago.ImportePagoVenta = importeMovimiento
Pago.ImportePago = importeMovimiento
Pago.CveIE = CveIEAnticipo
Pago.CveMonedaPago = gvr.DataKey("CveMoneda").ToEntero()
Pago.TCPago = gvr.DataKey("TipoCambio").ToDecimal
Pago.TipoPago = "NC"
Pago.CveVentaAmortizacion = gvr.DataKey("CveVenta").ToEntero()
Pago.AplicaTraslado = gvr.DataKey("RegresarImpuesto") = "1"
ErrorConta = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta)
SimplificaPrePoliza = False
End If
Case "66"
If gvr.DataKey("CveIE").ToEntero() > 0 Then
CveIEAnticipo = gvr.DataKey("CveIE").ToEntero()
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
IdCtaContable = IdCtaContClientes
If importeMovimiento <> 0 Then
Dim Pago As New VentaPago
Pago.ImportePago = importeMovimiento
Pago.CveIE = CveIEAnticipo
Pago.CveMonedaPago = gvr.DataKey("CveMoneda").ToEntero()
Pago.TipoPago = "A"
Pago.CveVentaAmortizacion = gvr.DataKey("CveVenta").ToEntero()
Pago.AplicaTraslado = gvr.DataKey("RegresarImpuesto") = "1"
ErrorConta = AplicaPrePolizaPagoVenta(VentaActual, Pago, CvePrePoliza, ObjConta)
' Agregamos el 2
If tipoCambioPago = 1 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 2, Concepto, Now, IdCtaContClientes, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
Else 'Cuando son dolares
If importeMovimiento <> 0 Then
If IdCtaContComplementaria > 0 Or 0 > 0 Then
'Agregamos la Complementaria
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, 0, Concepto, 207, Concepto, Now, IdCtaContComplementaria, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta - importeMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, CveCuenta:=0, TipoCambio:=tipoCambioVenta, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 2, Concepto, Now, IdCtaContMonedaExtranjera, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento, ImporteME:=importeMovimiento, CveCuenta:=0, TipoCambio:=tipoCambioVenta, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
Else
'Agregamos la Extranjera
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Concepto, 2, Concepto, Now, IdCtaContMonedaExtranjera, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, CveCuenta:=0, TipoCambio:=tipoCambioVenta, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
End If
End If
importeMovimiento = ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / TxtTotal.Text.ToDecimal) * TxtIVA.Text.ToDecimal)
importeMN = Math.Round(importeMovimiento * tipoCambioPago, 2, MidpointRounding.AwayFromZero)
'Agregamos el 92
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal 'gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("TotalAnticipo" & gvr.RowIndex).ToDecimal) * gvr.DataKey("IVAAnticipo").ToDecimal)
importeMN = Math.Round(importeMovimiento * tipoCambioPago, 2, MidpointRounding.AwayFromZero)
IdCtaContable = IdCtaContAnticipos
If ObjCliente.GetClientes(gvr.DataKey("CveCliente").ToEntero(), "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
If Not tipoCambioPago = 1 Then
IdCtaContable = ObjCliente.IdCtaMonedaExtranjeraAnticipos
Else
IdCtaContable = ObjCliente.IdCtaContAnticipos
End If
End If
End If
If UsuarioActual.CveEmpresa.Contiene(119) Then
If gvr.DataKey("Fecha").ToDate.Year <= 2017 AndAlso TxtFechaAnticipoCliente.Text.ToDate.Year >= 2018 Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
If Not tipoCambioPago = 1 Then
IdCtaContable = ObjCliente.IdCtaContMonedaExtranjera
Else
IdCtaContable = ObjCliente.IdCtaContClientes
End If
End If
End If
End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, 555, Concepto, Now, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMN, CveCuenta:=-1, TipoCambio:=tipoCambioPago, CveSubProyecto:=CveSubProyectoVenta) Then
ErrorConta = True
End If
End If
End If
End Select
End If
Next
Else