--Traspasar saldo de remisiones a factura global.
PA: --PA_Vta_VentasRemisionesPagos
This commit is contained in:
@@ -9279,7 +9279,7 @@ Public Class ClsPaginas
|
||||
#End Region
|
||||
|
||||
#Region "P A G O D E V E N T A S "
|
||||
Public Shared 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, Optional AplicarConceptoAplicacion As Boolean = True) As Boolean
|
||||
Dim ErrorMovtos As Boolean = False
|
||||
Dim PorcentajePago As Decimal = Pago.ImportePagoVenta / VentaActual.Total
|
||||
Dim ImporteMovimiento As Decimal = 0
|
||||
@@ -9401,7 +9401,7 @@ Public Class ClsPaginas
|
||||
End If
|
||||
|
||||
'concepto pago
|
||||
If Pago.TipoPago = "B" AndAlso Not ErrorMovtos Then ' B A N C O S
|
||||
If Pago.TipoPago = "B" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' B A N C O S
|
||||
Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
|
||||
If Pago.CveMonedaPago > 1 Then
|
||||
'Agregamos la Extranjera
|
||||
@@ -9413,7 +9413,7 @@ Public Class ClsPaginas
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 30, Pago.Referencia, Concepto, 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 = "A" AndAlso Not ErrorMovtos Then ' A N T I C I P O
|
||||
If Pago.TipoPago = "A" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' A N T I C I P O
|
||||
Concepto = String.Format("{0} Ant:{1}", VentaActual.ClienteNombre, Pago.Referencia)
|
||||
Dim Ret As New ConceptosRetenciones
|
||||
'Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, VentaActual.CveMoneda, True, 1)
|
||||
@@ -9427,7 +9427,7 @@ Public Class ClsPaginas
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, 11, Pago.Referencia, Concepto, CveVenta:=Pago.CveVentaAmortizacion, 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
|
||||
If Pago.TipoPago = "NC" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' N O T A D E C R E D I T O
|
||||
Concepto = String.Format("{0} NC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
|
||||
Dim Ret As New ConceptosRetenciones
|
||||
Dim ConPrePNC As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(6, Pago.CveMonedaPago, True, 2)
|
||||
@@ -9441,7 +9441,7 @@ Public Class ClsPaginas
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Pago.ImportePago, Pago.ImportePago, ConPrePNC.CveConcepto, Pago.Referencia, Concepto, 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
|
||||
If Pago.TipoPago = "I" AndAlso Not ErrorMovtos AndAlso AplicarConceptoAplicacion Then ' I N G R E S O S X C O M P R O B A R
|
||||
Concepto = String.Format("{0} IxC:{1}", VentaActual.ClienteNombre, Pago.Referencia)
|
||||
Dim Ret As New ConceptosRetenciones
|
||||
If VentaActual.UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
||||
|
||||
@@ -4097,6 +4097,49 @@ Namespace Modelos
|
||||
ErrorList.Add("No se pueden facturar las remisiones, con ese tipo de comprobante seleccionado")
|
||||
Else
|
||||
If ObjFactura.RemisionesLista.Count > 0 Then
|
||||
|
||||
'CANCELACION DE PAGOS DE REMISIONES
|
||||
If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then
|
||||
For Each DrPago As DataRow In DtPagosFacturaGlobal.Rows
|
||||
|
||||
Dim ventaRef As ClsPaginas.Venta = Nothing
|
||||
|
||||
Using ObjFacturaRef As New Modelos.Factura(UsuarioActual, DrPago("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
|
||||
ventaRef = New ClsPaginas.Venta(ObjFacturaRef, UsuarioActual)
|
||||
End Using
|
||||
|
||||
If ventaRef IsNot Nothing Then
|
||||
Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal() * -1
|
||||
|
||||
Dim Pago As New ClsPaginas.VentaPago
|
||||
Pago.Fecha = Now
|
||||
Pago.FechaDocumentoRelacionado = DrPago("FechaDocumento").ToString().ToDate
|
||||
Pago.ImportePagoVenta = Importe
|
||||
Pago.ImportePago = Importe
|
||||
Pago.CveIE = DrPago("CveIE").ToString().ToEntero()
|
||||
Pago.CveMonedaPago = DrPago("CveMoneda").ToString().ToEntero()
|
||||
Pago.TCPago = DrPago("TipoCambio").ToString().ToDecimal()
|
||||
Pago.AplicaTraslado = False
|
||||
Pago.Referencia = DrPago("Folio").ToString()
|
||||
Pago.CveVentaAmortizacion = -1
|
||||
|
||||
If DrPago("TipoPago").ToString() = "NC" Then
|
||||
Pago.TipoPago = "NC"
|
||||
Else
|
||||
Pago.TipoPago = "B"
|
||||
End If
|
||||
|
||||
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=False)
|
||||
Else
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
|
||||
If ErrorPrepoliza Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
For Each CveRemision As Integer In RemisionesLista
|
||||
If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then
|
||||
ErrorPrepoliza = True
|
||||
@@ -4115,6 +4158,42 @@ Namespace Modelos
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
'TRASPASO DE PAGOS DE REMISIONES A FACTURA GLOBAL
|
||||
If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then
|
||||
|
||||
Dim VentaActual As New ClsPaginas.Venta(ObjFactura, UsuarioActual)
|
||||
|
||||
For Each DrPago As DataRow In DtPagosFacturaGlobal.Rows
|
||||
Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal()
|
||||
|
||||
Dim Pago As New ClsPaginas.VentaPago
|
||||
Pago.Fecha = Now
|
||||
Pago.FechaDocumentoRelacionado = DrPago("FechaDocumento").ToString().ToDate
|
||||
Pago.ImportePagoVenta = Importe
|
||||
Pago.ImportePago = Importe
|
||||
Pago.CveIE = DrPago("CveIE").ToString().ToEntero()
|
||||
Pago.CveMonedaPago = DrPago("CveMoneda").ToString().ToEntero()
|
||||
Pago.TCPago = DrPago("TipoCambio").ToString().ToDecimal()
|
||||
Pago.AplicaTraslado = False
|
||||
Pago.Referencia = DrPago("Folio").ToString()
|
||||
Pago.CveVentaAmortizacion = DrPago("CveVenta").ToString().ToEntero()
|
||||
|
||||
If DrPago("TipoPago").ToString() = "NC" Then
|
||||
Pago.TipoPago = "NC"
|
||||
Else
|
||||
Pago.TipoPago = "B"
|
||||
End If
|
||||
|
||||
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(VentaActual, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=False)
|
||||
|
||||
If ErrorPrepoliza Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -4125,6 +4204,7 @@ Namespace Modelos
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
'REGRESA SALDO A LAS REMISIONES QUE SE FACTURARON EN EL INGRESO QUE SE ESTA CANCELANDO
|
||||
'SE DEBE DE EXCLUIR CUANDO ES REFACTURACIÓN
|
||||
If ObjFactura.TipoDocto = "Ing" And ValorMultiplicador = -1 AndAlso CveEstatusRefacturacion = 0 AndAlso Not SeCancelaRemisionProceso AndAlso DtRemisionesRelacionadas IsNot Nothing Then ' se debe de excluir cuando es refacturación
|
||||
@@ -7396,6 +7476,7 @@ Namespace Modelos
|
||||
Public Property DtPromociones As Data.DataTable
|
||||
Public Property DtImpuestosLocales As Data.DataTable
|
||||
Public Property DtPagos As Data.DataTable
|
||||
Public Property DtPagosFacturaGlobal As Data.DataTable
|
||||
Public Property DtRemisionesPS As Data.DataTable
|
||||
Public Property DtRemisiones As Data.DataTable
|
||||
Public Property DtPedidos2 As Data.DataTable
|
||||
|
||||
@@ -171,7 +171,7 @@ Partial Class Ventas_FacturacionGlobal
|
||||
SbRemisiones.Remove(SbRemisiones.Length - 1, 1)
|
||||
|
||||
Dim DtRemisionesPS As New DataTable()
|
||||
Dim DtPagos As New DataTable()
|
||||
Dim DtPagosFacturaGlobal As New DataTable()
|
||||
|
||||
Dim ObjClientes As New ClsClientes
|
||||
If ObjClientes.GetVentasRemisionesTotales(CveCliente, SbRemisiones.ToString(), 1) Then
|
||||
@@ -179,7 +179,7 @@ Partial Class Ventas_FacturacionGlobal
|
||||
End If
|
||||
|
||||
If ObjClientes.GetVentasRemisionesPagos(CveCliente, SbRemisiones.ToString()) Then
|
||||
DtPagos = ObjClientes.DtResultados.Copy()
|
||||
DtPagosFacturaGlobal = ObjClientes.DtResultados.Copy()
|
||||
End If
|
||||
ObjClientes.Dispose()
|
||||
|
||||
@@ -188,7 +188,7 @@ Partial Class Ventas_FacturacionGlobal
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0 Then
|
||||
If DtPagosFacturaGlobal Is Nothing OrElse DtPagosFacturaGlobal.Rows.Count = 0 Then
|
||||
Alert("No se pudieron cargar los pagos", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
@@ -211,7 +211,7 @@ Partial Class Ventas_FacturacionGlobal
|
||||
ObjFactura.RemisionesLista = RemisionesLista
|
||||
ObjFactura.DtRemisionesPS = DtRemisionesPS
|
||||
ObjFactura.DtRemisiones = DtRemisiones.FiltraParametros($"CveVenta IN ({SbRemisiones.ToString()})")
|
||||
ObjFactura.DtPagos = DtPagos
|
||||
ObjFactura.DtPagosFacturaGlobal = DtPagosFacturaGlobal
|
||||
|
||||
For Each Dr As DataRow In DtRemisionesPS.Rows
|
||||
ObjFactura.AgregarPS(Dr("CvePS").ToString().ToEntero(), Dr("Cantidad").ToString().ToDecimal(), Dr("PU").ToString().ToDecimal(), Dr("Descuento").ToString().ToDecimal, Dr("Obs").ToString(), CveUM:=Dr("CveUM").ToString().ToEntero(),
|
||||
@@ -221,7 +221,7 @@ Partial Class Ventas_FacturacionGlobal
|
||||
ObjFactura.CalculaTotales()
|
||||
ObjFactura.PreparaTimbre()
|
||||
|
||||
If ObjFactura.Total <> DtPagos.SUMD("Importe") Then
|
||||
If ObjFactura.Total <> DtPagosFacturaGlobal.SUMD("Importe") Then
|
||||
Alert("Los pagos no coinciden con el total de la factura", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user