From a1dac5abf76ff7365ad7a55e0b4462f24a3d4e09 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sat, 12 Oct 2019 15:55:26 -0700 Subject: [PATCH] Validacion de amortizaciones de NC --- Ventas/Ventas.aspx.vb | 249 ++++++++++++++++++++++-------------------- 1 file changed, 130 insertions(+), 119 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index e5c3f76e1..36d8b66a2 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -7306,7 +7306,7 @@ Partial Class Ventas ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion) 'Registramos la venta - GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, tmpcon, -1, ObjContPaq, ObjBancos) + GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, tmpcon, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True) ''Timbramos 'If factura.TipoDocto.Contiene("Ing", "Egs", "Ant") Then @@ -8801,7 +8801,9 @@ Partial Class Ventas #Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO " - Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing) + Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer, + ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, + ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False) Dim Msgok As New StringBuilder Dim CveAlmacenTraspasoOrigen As Integer = -1 @@ -9125,8 +9127,10 @@ Partial Class Ventas GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos) If ErrorList.Count = 0 Then 'inventarios - If GuardarVentaInventarios(ObjInventario, ObjConta, factura) Then - ErrorList.Add("Ocurrio un error al Guardar Inventario") + If Not EsNCAmortizacion Then + If GuardarVentaInventarios(ObjInventario, ObjConta, factura) Then + ErrorList.Add("Ocurrio un error al Guardar Inventario") + End If End If If ErrorList.Count = 0 Then 'estimaciones @@ -9147,7 +9151,9 @@ Partial Class Ventas End If End Sub - Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing) + Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, + ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, + ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False) Dim CveIE As Integer = -1 Dim DT As DataTable = Nothing @@ -9175,7 +9181,9 @@ Partial Class Ventas End If End If End Sub - Private Function ProcesoPrepolizas(ByRef ObjConta As ClsContabilidad, ObjFactura As Modelos.Factura, 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) As Boolean + Private Function ProcesoPrepolizas(ByRef ObjConta As ClsContabilidad, ObjFactura As Modelos.Factura, 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 EsNCAmortizacion As Boolean = False) As Boolean Try Dim DT As DataTable Dim CvePlantilaPoliza As Integer @@ -9422,146 +9430,149 @@ Partial Class Ventas TipoCambioNC = GlobalTipoCambio(TxtFecha.Text.ToDate).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 + If Not EsNCAmortizacion Then + '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 ImporteMN251 As Decimal = 0 + Dim Importe91 As Decimal = 0 + Dim ImporteMN91 As Decimal = 0 + Dim Importe251 As Decimal = 0 + Dim ImporteMN251 As Decimal = 0 - 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 + 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 - Importe91 = Dr("Importe").ToString.ToDecimal / TipoCambioNC - ImporteMN91 = Dr("Importe").ToString.ToDecimal - End If - - Dim TCFluctuacion As Decimal = Dr("TCCambioValuacion").ToString.ToDecimal - If TCFluctuacion = 1 AndAlso TipoCambioNC > 1 Then - TCFluctuacion = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal - End If - - 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 * Multiplicador).RoundSQL - - Importe91 = (Importe91 * ValorMultiplicador).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 + Importe91 = Dr("Importe").ToString.ToDecimal / TipoCambioNC + ImporteMN91 = Dr("Importe").ToString.ToDecimal 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 - 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 + Dim TCFluctuacion As Decimal = Dr("TCCambioValuacion").ToString.ToDecimal + If TCFluctuacion = 1 AndAlso TipoCambioNC > 1 Then + TCFluctuacion = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal End If - End If - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 251, 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 - - '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 - IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + 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 - CveConceptoFluctua = 64 - TipoMovtoFluctua = True - IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaGananciaCambiaria - CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + ImporteMN251 = Dr("Importe").ToString.ToDecimal 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, CveCuenta:=CveCuenta) Then + Importe251 = (Importe251 * Multiplicador).RoundSQL + + Importe91 = (Importe91 * ValorMultiplicador).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 + 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 - End If + ImporteAcumulado91 += (ImporteMN91).RoundSQL - Next + 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 + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, Importe251, Referencia, 251, 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 - 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 + + '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 + IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria + Else + CveConceptoFluctua = 64 + TipoMovtoFluctua = True + IdCtaContableFluctua = UsuarioActual.Empresa.IdCuentaGananciaCambiaria + CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria + 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, CveCuenta:=CveCuenta) Then + ErrorPrepoliza = True + Exit For + End If + End If + + 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 - Else - ErrorPrepoliza = True End If - End If - If 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") + If 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 + 'SIRVE PARA VER LA PREPOLIZA QUE SE VALIDA + 'If ObjConta.GetPrePolizasDetalle(ObjFactura.CvePrePoliza) Then + ' Dim DtTest = ObjConta.DtResultados + 'End If + End If End If - End If - If ErrorPrepoliza Then - Exit For + If ErrorPrepoliza Then + Exit For + End If End If End If + 'APLICA DEVOLUCION SALDOS DIRECTOS If AplicaDevolucion Then Dim importeMovimientoDev = TxtTotal.Text.ToDecimal