Aplicar NC en anticipos

This commit is contained in:
2020-03-09 19:40:01 -07:00
parent e12d85ac72
commit ad5b4fd47f
2 changed files with 93 additions and 8 deletions

View File

@@ -499,6 +499,15 @@ Namespace Modelos
If ObjVentas.GetVentasAntNC(-1, CveVenta, AplicaAmortizacion:=EsNCAmortizacion) Then
Me.DtAnticipos = ObjVentas.DtResultados.Copy()
End If
If (DtAnticipos Is Nothing OrElse DtAnticipos.Rows.Count = 0) Then
'SI ES EGRESO Y TIENE ANTICIPOS VINCULADOS
If TipoDocto.Contiene("Egs") AndAlso EsNCAmortizacion AndAlso EsCancelacion Then
If ObjVentas.GetVentasAntNC(CveVenta, -1, AplicaAmortizacion:=EsNCAmortizacion) Then
Me.DtAnticipos = ObjVentas.DtResultados.Copy()
End If
End If
End If
End If
End If
@@ -2484,6 +2493,12 @@ Namespace Modelos
CveVentaAmortizacion = ObjFactura.CveVenta
End If
'SI ES EGRESO Y TIENE ANTICIPOS VINCULADOS
If (ObjFactura.TipoDocto.Contiene("Egs") AndAlso row2("TipoDocto").ToString() = "Ant" AndAlso EsNCAmortizacion) Then
CveVenta = row2("CveVenta").ToString().ToEntero
CveVentaAmortizacion = ObjFactura.CveVenta
End If
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1,
CveVenta:=CveVenta, CveVentaAmortizacion:=CveVentaAmortizacion, CveCliente:=ObjFactura.CveCliente,
@@ -2505,9 +2520,9 @@ Namespace Modelos
' cuando es amortización de nota de crédito, y es la nc
' cuando es amortización por descuento, y es el ingreso
' cuando es amortización en cero
If ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") OrElse
If (ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") OrElse
ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse
ObjFactura.CveTipoAmortizacionAnticipo = 3 Then
ObjFactura.CveTipoAmortizacionAnticipo = 3) Then
For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
If row2("CveConceptoContable").ToString().ToEntero = 11 Then
CveIEAnticipo = -1
@@ -5316,6 +5331,7 @@ Namespace Modelos
Public Property DtContratosSerieDetalle As Data.DataTable
Public Property DtOtrosConceptos As Data.DataTable
Public Property DtInventario As Data.DataTable
'Public Property DtAnticipoAmortizacion As Data.DataTable
Public Property DtRemConceptosSurtidos As Data.DataTable
Public Property UsadosBonificacion As List(Of Integer)
Public Property TipoBonificacion As Integer = 0

View File

@@ -1184,6 +1184,22 @@ Partial Class Ventas
ViewState("PermiteCredito") = value
End Set
End Property
Private Property DtAnticipoAmortizacion As DataTable
Get
Return CType(ViewState("DtAnticipoAmortizacion"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtAnticipoAmortizacion") = value
End Set
End Property
Private Property SaldoAnticipo As Decimal
Get
Return If(IsNothing(ViewState("SaldoAnticipo")), 0, ViewState("SaldoAnticipo").ToString().ToDecimal())
End Get
Set(value As Decimal)
ViewState("SaldoAnticipo") = value
End Set
End Property
#End Region
@@ -3699,7 +3715,14 @@ Partial Class Ventas
LblNCSaldoAnticipo.Visible = True
ChkAplicaNCAnticipo.Visible = True
ChkAplicaNCAnticipo.Checked = True
If DbRowVenta("SaldoAnticipo").ToString.ToDouble <= 0 Then ChkAplicaNCAnticipo.Checked = False : ChkAplicaNCAnticipo.Enabled = False
Me.SaldoAnticipo = DbRowVenta("SaldoAnticipo").ToString.ToDecimal
If SaldoAnticipo > 0 Then
InicializaDTAnticiposAmortizacion()
ChkAplicaNCAnticipo.Enabled = False
Else
ChkAplicaNCAnticipo.Checked = False
End If
'If DbRowVenta("SaldoAnticipo").ToString.ToDouble <= 0 Then ChkAplicaNCAnticipo.Checked = False : ChkAplicaNCAnticipo.Enabled = False
LblNCSaldoAnticipo.Text = String.Format("Saldo Anticipo: $ {0}", DbRowVenta("SaldoAnticipo").ToString.ToDouble.FormatoNumero)
Case "Dev"
DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev"))
@@ -6581,7 +6604,7 @@ Partial Class Ventas
EsValidoPU = False ' SI NO TIENE PROMOCION NO SE PUEDE VENDER A 0
End If
End If
EsValido = True
'NO DEJA REGISTRAR CON VALIDACION DE COSTO ALMACEN O PROMOCION
Dim TienePermisoImportes As Boolean = UsuarioActual.TienePermisoProceso(201)
If Not EsValido Then
@@ -9320,7 +9343,7 @@ Partial Class Ventas
Next
End If
Dim CveTipoRetencion As Integer = -1
Dim CveTipoRetencion As Integer = 0
If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then
CveTipoRetencion = DdlTipoRetencion.SelectedValue.ToEntero()
End If
@@ -10193,6 +10216,31 @@ Partial Class Ventas
Next
End If
'CUANDO APLICAN UNA NOTA DE CREDITO SOBRE UN ANTICIPO
If ObjFactura.TipoDocto = "Egs" AndAlso EsNCAmortizacion Then
If DtAnticipoAmortizacion IsNot Nothing AndAlso DtAnticipoAmortizacion.Rows.Count > 0 Then
For Each RowAnticipo As DataRow In DtAnticipoAmortizacion.Rows
Dim CveVentaAnticipo As Integer = RowAnticipo("CveVenta").ToString().ToEntero
importeMovimiento = RowAnticipo("SaldoAnticipo").ToString().ToDecimal
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
IdCtaContable = IdCtaContAnticipos
CveCuenta = CveCuentaAnticipos
CveSubProyectoContabilizar = CveSubProyectoVenta
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVentaAnticipo, CveVentaAmortizacion:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, ImporteMX:=importeMovimiento * tipoCambio, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
Else
ViewState("SeGuardoPrePoliza") = True
End If
End If
Next
End If
End If
'cuando es anticipo
' cuando es amortización de nota de crédito, y es la nc
' cuando es amortización por descuento, y es el ingreso
@@ -21440,12 +21488,12 @@ Partial Class Ventas
End If
DdlTipoComprobante.SelectedValue = "Egs"
AplicarNC(DdlNCPS.SelectedValue.ToEntero)
AplicarNC(DdlNCPS.SelectedValue.ToEntero, EsNCAmortizacion:=ChkAplicaNCAnticipo.Checked)
RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC")
End Sub
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False)
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False)
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DrPS Is Nothing Then
Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError)
@@ -21461,6 +21509,7 @@ Partial Class Ventas
Exit Sub
End If
End If
'CREAMOS DT PARA UTILIZAR AL TIMBRAR
InicializaDTVentasNC()
@@ -21497,6 +21546,21 @@ Partial Class Ventas
End If
Else
DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal)
If EsNCAmortizacion Then
If DtAnticipoAmortizacion Is Nothing Then
InicializaDTAnticiposAmortizacion()
End If
Dim PorcentajeAplicado As Decimal = (TxtNCPorcentaje.Text.ToDecimal / 100D)
Dim RowAnticipo As DataRow = DtAnticipoAmortizacion.NewRow
RowAnticipo("CveVenta") = Me.CveVenta
RowAnticipo("Importe") = TxtNCImporte.Text.Trim.ToDecimal
RowAnticipo("SaldoAnticipo") = SaldoAnticipo * PorcentajeAplicado
DtAnticipoAmortizacion.Rows.Add(RowAnticipo)
End If
End If
Dim query = From dr In DtImpuestos
@@ -21834,7 +21898,12 @@ Partial Class Ventas
BloqueaCondiconesPago()
End Sub
Private Sub InicializaDTAnticiposAmortizacion()
Me.DtAnticipoAmortizacion = New DataTable
Me.DtAnticipoAmortizacion.Columns.Add("CveVenta", GetType(Integer))
Me.DtAnticipoAmortizacion.Columns.Add("Importe", GetType(Decimal))
Me.DtAnticipoAmortizacion.Columns.Add("SaldoAnticipo", GetType(Decimal))
End Sub
Private Sub InicializaDTVentasNC()
DtVentasNC = New DataTable
DtVentasNC.Columns.Add("CveVenta", GetType(Integer))