Pendientes BDH
This commit is contained in:
@@ -3672,6 +3672,10 @@ Partial Class Ventas
|
||||
DdlEstadoSAT.DataBind()
|
||||
DdlEstadoSAT.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
||||
|
||||
If UsuarioActual.CveEmpresa = 140 AndAlso ClaveSATPais = "MEX" Then
|
||||
DdlEstadoSAT.SelectedValueExist("26")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Protected Sub DdlSATPais_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
CargaEstados(DdlSATPais.SelectedValue)
|
||||
@@ -8306,6 +8310,7 @@ Partial Class Ventas
|
||||
If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then
|
||||
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" CveSubProyecto = {0} And Estado = 'Activo'", DdlSubProyectoDatos.SelectedValue.ToEntero()))
|
||||
If DT.Rows.Count > 0 Then
|
||||
factura.Serie = DT.Rows(0)("Serie").ToString()
|
||||
factura.Folio = DT.Rows(0)("FActual").ToString().ToEntero()
|
||||
Else
|
||||
ProcesoCorrecto = False
|
||||
@@ -8493,6 +8498,11 @@ Partial Class Ventas
|
||||
ObjFactura.FacturarSucursal = (Me.FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ClienteSucursal.RFC)))
|
||||
ObjFactura.VentaDesglosaIEPS = Me.VentaDesglosaIEPS
|
||||
'ObjFactura.RefDocto = TxtDocto.Text.Trim
|
||||
|
||||
If EsCreaApartirDe Then
|
||||
ViewState("EstablecioFolio") = False
|
||||
End If
|
||||
|
||||
'si es cancelacion, debe de conservar el folio actual
|
||||
If Not EsCancelacion Then ObjFactura.Folio = If(EstablecioFolio Or VistaPrevia Or (CveVenta > 0 And (NuevaFactura.Contiene(0, 2))), TxtFolio.Text.Trim.ToEntero(), -1)
|
||||
|
||||
@@ -10091,11 +10101,6 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not GuardarUsados(ObjVentas.IniciaTransacSQL, ObjVentas.CveVenta) Then
|
||||
ErrorList.Add("Error al guardar usados")
|
||||
End If
|
||||
|
||||
|
||||
If ErrorList.Count = 0 AndAlso ObjVentas.CveVenta > 0 Then
|
||||
|
||||
factura.CveVenta = ObjVentas.CveVenta
|
||||
@@ -10105,6 +10110,10 @@ Partial Class Ventas
|
||||
factura.Timbre.Comprobante.Serie = ObjVentas.Serie
|
||||
factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString()
|
||||
|
||||
If Not GuardarUsados(ObjVentas.IniciaTransacSQL, factura) Then
|
||||
ErrorList.Add("Error al guardar usados")
|
||||
End If
|
||||
|
||||
If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then
|
||||
If DtVentasNC Is Nothing Then
|
||||
InicializaDTVentasNC()
|
||||
@@ -16878,9 +16887,9 @@ Partial Class Ventas
|
||||
|
||||
Protected Sub BtnAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarSucursal.Click
|
||||
|
||||
Dim LT As String = "0"
|
||||
Dim LG As String = "0"
|
||||
|
||||
Dim LT As String = "0"
|
||||
Dim LG As String = "0"
|
||||
|
||||
If CveCliente > 0 Then
|
||||
Dim ObjCliente As New ClsClientes
|
||||
Try
|
||||
@@ -16925,13 +16934,13 @@ Partial Class Ventas
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al agregar la sucursal", ex)
|
||||
End Try
|
||||
ObjCliente.Dispose()
|
||||
|
||||
End If
|
||||
|
||||
UpCliente.Update()
|
||||
RegistraScript("hideDivAgregarSucursal();")
|
||||
|
||||
ObjCliente.Dispose()
|
||||
|
||||
End If
|
||||
|
||||
UpCliente.Update()
|
||||
RegistraScript("hideDivAgregarSucursal();")
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -23078,6 +23087,7 @@ Partial Class Ventas
|
||||
|
||||
Me.TmpDTRNCBonificacionesCliente = DtNC.FiltraParametros("TipoRNC = 2")
|
||||
Me.TmpDTRNCBonificacionesCliente.Columns.Add("ImporteBonificacion", GetType(Decimal))
|
||||
Me.TmpDTRNCBonificacionesCliente.Columns.Add("IVABonificacion", GetType(Decimal))
|
||||
Me.TmpDTRNCBonificacionesCliente.Columns.Add("CveVentaRNCCargo", GetType(Integer))
|
||||
|
||||
GvRemisionesNC.DataBind()
|
||||
@@ -23085,7 +23095,7 @@ Partial Class Ventas
|
||||
|
||||
If CveVentaUsado > 0 Then
|
||||
Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa)
|
||||
LtlSMU.Text = String.Format("{0:N2}", FacUsado.DtDetalle.SUM("Total", "EsCargo = True").ToDecimal())
|
||||
LtlSMU.Text = String.Format("{0:N2}", FacUsado.DtDetalle.SUM("Total", "EsCargo = True").ToDecimal() + FacUsado.DtDetalle.SUM("ImporteIVA", "EsCargo = True").ToDecimal())
|
||||
Else
|
||||
LtlSMU.Text = String.Format("{0:N2}", 0)
|
||||
End If
|
||||
@@ -23107,12 +23117,16 @@ Partial Class Ventas
|
||||
|
||||
Me.TmpDTRNCBonificacionesCliente = DtNC.FiltraParametros("TipoRNC = 2")
|
||||
Me.TmpDTRNCBonificacionesCliente.Columns.Add("ImporteBonificacion", GetType(Decimal))
|
||||
Me.TmpDTRNCBonificacionesCliente.Columns.Add("IVABonificacion", GetType(Decimal))
|
||||
Me.TmpDTRNCBonificacionesCliente.Columns.Add("CveVentaRNCCargo", GetType(Integer))
|
||||
|
||||
GvDescNCCargos.DataBind()
|
||||
GvDescNCBonificaciones.DataBind()
|
||||
|
||||
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal())
|
||||
Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
|
||||
|
||||
LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados)
|
||||
HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString()
|
||||
|
||||
UpDescNC.Update()
|
||||
End Sub
|
||||
@@ -23125,28 +23139,52 @@ Partial Class Ventas
|
||||
TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone()
|
||||
End If
|
||||
|
||||
Dim CveVentaBonificacion As Integer = -1
|
||||
Dim ImporteBonificacion As Decimal = 0
|
||||
Dim ListaBon As New List(Of VentasBonificaciones)
|
||||
Dim DtBon As DataTable = Nothing
|
||||
Dim SbFiltro As New StringBuilder()
|
||||
SbFiltro.Append("CveVenta IN(")
|
||||
Using ObjAcum As New ClsAcumuladores
|
||||
If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=GvRow.DataKey("CveVenta").ToEntero()) Then
|
||||
Dim RowMovto As DataRow = ObjAcum.DtResultados.FiltroPrimero("")
|
||||
|
||||
CveVentaBonificacion = RowMovto("CveVentaBonificacion").ToString().ToEntero()
|
||||
ImporteBonificacion = RowMovto("ImporteBonificacion").ToString().ToDecimal()
|
||||
DtBon = ObjAcum.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
|
||||
If CveVentaBonificacion > 0 Then
|
||||
Dim RowBonificacion As DataRow = Me.TmpDTRNCBonificacionesCliente.FiltroPrimero($"CveVenta = {CveVentaBonificacion}")
|
||||
RowBonificacion("ImporteBonificacion") = ImporteBonificacion
|
||||
RowBonificacion("CveVentaRNCCargo") = GvRow.DataKey("CveVenta").ToEntero()
|
||||
If DtBon IsNot Nothing Then
|
||||
Dim queryBonificacion = From dr In DtBon
|
||||
Group By CveVentaBonificacion = dr("CveVentaBonificacion").ToString().ToEntero
|
||||
Into x = Group
|
||||
Select New With {
|
||||
.CveVentaBonificacion = CveVentaBonificacion,
|
||||
.ImporteBonificacion = x.Sum(Function(s) s("ImporteBonificacion").ToString().ToDecimal),
|
||||
.IVABonificacion = x.Sum(Function(s) s("IVABonificacion").ToString().ToDecimal)
|
||||
}
|
||||
|
||||
If ChkAplicarRNC.Checked Then
|
||||
TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray)
|
||||
Else
|
||||
Dim RowEliminar As DataRow = Me.TmpDTRNCBonificacionesSeleccionadas.Select($"CveVenta = {CveVentaBonificacion}").FirstOrDefault()
|
||||
TmpDTRNCBonificacionesSeleccionadas.Rows.Remove(RowEliminar)
|
||||
End If
|
||||
For Each bon In queryBonificacion
|
||||
SbFiltro.AppendFormat("'{0}',", bon.CveVentaBonificacion)
|
||||
ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero(), .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion})
|
||||
Next
|
||||
SbFiltro.Remove(SbFiltro.Length - 1, 1)
|
||||
SbFiltro.Append(")")
|
||||
End If
|
||||
|
||||
If ListaBon.Count > 0 Then
|
||||
Dim Bonificaciones = Me.TmpDTRNCBonificacionesCliente.Select(SbFiltro.ToString())
|
||||
|
||||
For Each RowBonificacion As DataRow In Bonificaciones
|
||||
Dim RNCBonificacion = ListaBon.Where(Function(x) x.CveVentaBonificacion = RowBonificacion("CveVenta").ToString().ToEntero())
|
||||
|
||||
RowBonificacion("ImporteBonificacion") = RNCBonificacion.Sum(Function(x) x.ImporteBonificacion)
|
||||
RowBonificacion("IVABonificacion") = RNCBonificacion.Sum(Function(x) x.IVABonificacion)
|
||||
RowBonificacion("CveVentaRNCCargo") = GvRow.DataKey("CveVenta").ToEntero()
|
||||
|
||||
If ChkAplicarRNC.Checked Then
|
||||
TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray)
|
||||
Else
|
||||
For Each RowEliminar In Me.TmpDTRNCBonificacionesSeleccionadas.Select(SbFiltro.ToString())
|
||||
RowEliminar.Delete()
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
@@ -23160,7 +23198,7 @@ Partial Class Ventas
|
||||
GvDescNCBonificaciones.DataSource = TmpDTRNCBonificacionesSeleccionadas
|
||||
GvDescNCBonificaciones.DataBind()
|
||||
|
||||
LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal())
|
||||
LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal() + Me.TmpDTRNCBonificacionesSeleccionadas.SUM("IVABonificacion").ToDecimal())
|
||||
|
||||
UpDescNC.Update()
|
||||
|
||||
@@ -23173,28 +23211,52 @@ Partial Class Ventas
|
||||
TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone()
|
||||
End If
|
||||
|
||||
Dim CveVentaBonificacion As Integer = -1
|
||||
Dim ImporteBonificacion As Decimal = 0
|
||||
Dim ListaBon As New List(Of VentasBonificaciones)
|
||||
Dim DtBon As DataTable = Nothing
|
||||
Dim SbFiltro As New StringBuilder()
|
||||
SbFiltro.Append("CveVenta IN(")
|
||||
Using ObjAcum As New ClsAcumuladores
|
||||
If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=GvRow.DataKey("CveVenta").ToEntero()) Then
|
||||
Dim RowMovto As DataRow = ObjAcum.DtResultados.FiltroPrimero("")
|
||||
|
||||
CveVentaBonificacion = RowMovto("CveVentaBonificacion").ToString().ToEntero()
|
||||
ImporteBonificacion = RowMovto("ImporteBonificacion").ToString().ToDecimal()
|
||||
DtBon = ObjAcum.DtResultados.Copy()
|
||||
End If
|
||||
End Using
|
||||
|
||||
If CveVentaBonificacion > 0 Then
|
||||
Dim RowBonificacion As DataRow = Me.TmpDTRNCBonificacionesCliente.FiltroPrimero($"CveVenta = {CveVentaBonificacion}")
|
||||
RowBonificacion("ImporteBonificacion") = ImporteBonificacion
|
||||
RowBonificacion("CveVentaRNCCargo") = GvRow.DataKey("CveVenta").ToEntero()
|
||||
If DtBon IsNot Nothing Then
|
||||
Dim queryBonificacion = From dr In DtBon
|
||||
Group By CveVentaBonificacion = dr("CveVentaBonificacion").ToString().ToEntero
|
||||
Into x = Group
|
||||
Select New With {
|
||||
.CveVentaBonificacion = CveVentaBonificacion,
|
||||
.ImporteBonificacion = x.Sum(Function(s) s("ImporteBonificacion").ToString().ToDecimal),
|
||||
.IVABonificacion = x.Sum(Function(s) s("IVABonificacion").ToString().ToDecimal)
|
||||
}
|
||||
|
||||
If ChkAplicarRNC.Checked Then
|
||||
TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray)
|
||||
Else
|
||||
Dim RowEliminar As DataRow = Me.TmpDTRNCBonificacionesSeleccionadas.Select($"CveVenta = {CveVentaBonificacion}").FirstOrDefault()
|
||||
TmpDTRNCBonificacionesSeleccionadas.Rows.Remove(RowEliminar)
|
||||
End If
|
||||
For Each bon In queryBonificacion
|
||||
SbFiltro.AppendFormat("'{0}',", bon.CveVentaBonificacion)
|
||||
ListaBon.Add(New VentasBonificaciones() With {.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero(), .CveVentaBonificacion = bon.CveVentaBonificacion, .ImporteBonificacion = bon.ImporteBonificacion, .IVABonificacion = bon.IVABonificacion})
|
||||
Next
|
||||
SbFiltro.Remove(SbFiltro.Length - 1, 1)
|
||||
SbFiltro.Append(")")
|
||||
End If
|
||||
|
||||
If ListaBon.Count > 0 Then
|
||||
Dim Bonificaciones = Me.TmpDTRNCBonificacionesCliente.Select(SbFiltro.ToString())
|
||||
|
||||
For Each RowBonificacion As DataRow In Bonificaciones
|
||||
Dim RNCBonificacion = ListaBon.Where(Function(x) x.CveVentaBonificacion = RowBonificacion("CveVenta").ToString().ToEntero())
|
||||
|
||||
RowBonificacion("ImporteBonificacion") = RNCBonificacion.Sum(Function(x) x.ImporteBonificacion)
|
||||
RowBonificacion("IVABonificacion") = RNCBonificacion.Sum(Function(x) x.IVABonificacion)
|
||||
RowBonificacion("CveVentaRNCCargo") = GvRow.DataKey("CveVenta").ToEntero()
|
||||
|
||||
If ChkAplicarRNC.Checked Then
|
||||
TmpDTRNCBonificacionesSeleccionadas.Rows.Add(RowBonificacion.ItemArray)
|
||||
Else
|
||||
For Each RowEliminar In Me.TmpDTRNCBonificacionesSeleccionadas.Select(SbFiltro.ToString())
|
||||
RowEliminar.Delete()
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
@@ -23208,7 +23270,7 @@ Partial Class Ventas
|
||||
GvRemisionesNCBon.DataSource = TmpDTRNCBonificacionesSeleccionadas
|
||||
GvRemisionesNCBon.DataBind()
|
||||
|
||||
LtlSMUBon.Text = String.Format("{0:N2}", Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal())
|
||||
LtlSMUBon.Text = String.Format("{0:N2}", Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal() + Me.TmpDTRNCBonificacionesSeleccionadas.SUM("IVABonificacion").ToDecimal())
|
||||
|
||||
UpModalRemisionesNC.Update()
|
||||
|
||||
@@ -23570,7 +23632,7 @@ Partial Class Ventas
|
||||
Dim UltimoRenglonRNC As Integer = 1
|
||||
For Each RowUsado As DataRow In RNC.DtDetalle.Rows
|
||||
|
||||
Dim PorcentajeUsado = (RowUsado("Total").ToString().ToDecimal() - RowUsado("Descuento").ToString().ToDecimal() + RowUsado("ImporteIVA").ToString().ToDecimal() + RowUsado("ImporteIEPS").ToString().ToDecimal() - RowUsado("ImporteRetIVA").ToString().ToDecimal() - RowUsado("ImporteRetISR").ToString().ToDecimal()) / RNC.Total
|
||||
Dim PorcentajeUsado = ((RowUsado("Total").ToString().ToDecimal() - RowUsado("Descuento").ToString().ToDecimal() + RowUsado("ImporteIVA").ToString().ToDecimal() + RowUsado("ImporteIEPS").ToString().ToDecimal() - RowUsado("ImporteRetIVA").ToString().ToDecimal() - RowUsado("ImporteRetISR").ToString().ToDecimal()) / RNC.Total) / ListaNC.Count
|
||||
Dim Obs = RowUsado("CodigoPS").ToString()
|
||||
|
||||
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
|
||||
@@ -23615,7 +23677,7 @@ Partial Class Ventas
|
||||
|
||||
For Each RowCargo As DataRow In RNCCargo.DtDetalle.Rows
|
||||
|
||||
Dim PorcentajeCargo = (RowCargo("Total").ToString().ToDecimal() - RowCargo("Descuento").ToString().ToDecimal() + RowCargo("ImporteIVA").ToString().ToDecimal() + RowCargo("ImporteIEPS").ToString().ToDecimal() - RowCargo("ImporteRetIVA").ToString().ToDecimal() - RowCargo("ImporteRetISR").ToString().ToDecimal()) / RNCCargo.Total
|
||||
Dim PorcentajeCargo = ((RowCargo("Total").ToString().ToDecimal() - RowCargo("Descuento").ToString().ToDecimal() + RowCargo("ImporteIVA").ToString().ToDecimal() + RowCargo("ImporteIEPS").ToString().ToDecimal() - RowCargo("ImporteRetIVA").ToString().ToDecimal() - RowCargo("ImporteRetISR").ToString().ToDecimal()) / RNCCargo.Total) / ListaNCBonificacion.Count
|
||||
|
||||
Dim Obs = RowCargo("CodigoPS").ToString()
|
||||
|
||||
@@ -26505,29 +26567,21 @@ Partial Class Ventas
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, CveVenta As Integer) As Boolean
|
||||
Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, factura As Modelos.Factura) As Boolean
|
||||
Dim Resultado As Boolean = True
|
||||
|
||||
If ClienteEsDistribuidor Then
|
||||
'If UsuarioActual.Empresa.Funcionalidad(533).ToEntero() > 0 Then
|
||||
' Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero()
|
||||
|
||||
If ClienteEsDistribuidor AndAlso factura.TipoDocto.Contiene("Ing") Then
|
||||
Dim ObjAcum As New ClsAcumuladores(SqlTransaccion)
|
||||
|
||||
Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero
|
||||
|
||||
For Each drow As DataRow In TmpDT.Rows
|
||||
If drow("CveTamaño").ToString().ToEntero() > 0 Then
|
||||
Dim TempDTAcums = GlobalDTAcumTamaños.FiltraParametros("CvePSCargo = " & drow("CvePS").ToString())
|
||||
If TempDTAcums IsNot Nothing AndAlso TempDTAcums.Rows.Count > 0 Then
|
||||
If Not ObjAcum.DistribuidorMovtosAdd(CveCliente, drow("Cantidad").ToString().ToEntero(), drow("CveTamaño").ToString().ToEntero(), 2, CveVenta, UsuarioActual.CveUsuario,
|
||||
UsuarioActual.CveEmpresa, 0D, "") Then
|
||||
Resultado = False
|
||||
Exit For
|
||||
End If
|
||||
Else
|
||||
Resultado = True
|
||||
For Each drow As DataRow In factura.DtDetalle.Rows
|
||||
If drow("CveTamaño").ToString.ToEntero > 0 And (CvePSPSA <> drow("CvePS").ToString.ToEntero) Then
|
||||
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, 2, CveVenta, UsuarioActual.CveUsuario,
|
||||
UsuarioActual.CveEmpresa, 0D, "") Then
|
||||
Resultado = False
|
||||
Exit For
|
||||
End If
|
||||
TempDTAcums.Dispose()
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
@@ -26645,81 +26699,96 @@ Partial Class Ventas
|
||||
RegistraScript("$('#ModalAplicarDescuentoNC').modal('show'); ")
|
||||
End Sub
|
||||
Protected Sub BtnAplicarDesc_Click(sender As Object, e As EventArgs)
|
||||
Dim CveSATNC = "84111506"
|
||||
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
|
||||
Try
|
||||
Dim CveSATNC = "84111506"
|
||||
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
|
||||
|
||||
If DrPS Is Nothing Then
|
||||
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
AplicaNCMasiva = True
|
||||
|
||||
If ListaNCDesc Is Nothing Then
|
||||
ListaNCDesc = New List(Of Modelos.Factura)
|
||||
Else
|
||||
ListaNCDesc.Clear()
|
||||
End If
|
||||
|
||||
If ListaNCBonificacion Is Nothing Then
|
||||
ListaNCBonificacion = New List(Of Modelos.Factura)
|
||||
Else
|
||||
ListaNCBonificacion.Clear()
|
||||
End If
|
||||
|
||||
Dim TotalRemNCAplicado As Decimal = 0
|
||||
For Each GvRow As GridViewRow In GvDescNCCargos.Rows
|
||||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||||
If GvRow.FCCheckBox("ChkAplicar").Checked Then
|
||||
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
|
||||
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
|
||||
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
|
||||
|
||||
If RemNC.TotalRemNCAplicado <= 0 Then
|
||||
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCDesc.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ListaNCDesc.Add(RemNC)
|
||||
End If
|
||||
If DrPS Is Nothing Then
|
||||
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim LimiteUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal()
|
||||
AplicaNCMasiva = True
|
||||
|
||||
'VERIFICA EL LIMITE DE LOS USADOS
|
||||
If TotalRemNCAplicado > LimiteUsados Then
|
||||
Alert($"La suma de las remisiones de nota de crédito de tipo 'Cargo' no debe superar el total de Usados.<br/>Total RNC: {TotalRemNCAplicado:N2}.<br/>Total Usados: {LimiteUsados:N2}", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCDesc.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
For Each GvRow As GridViewRow In GvDescNCBonificaciones.Rows
|
||||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||||
If GvRow.FCCheckBox("ChkAplicar").Checked Then
|
||||
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
|
||||
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
|
||||
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero()
|
||||
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
|
||||
|
||||
If RemNC.TotalRemNCAplicado <= 0 Then
|
||||
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCBonificacion.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ListaNCBonificacion.Add(RemNC)
|
||||
End If
|
||||
If ListaNCDesc Is Nothing Then
|
||||
ListaNCDesc = New List(Of Modelos.Factura)
|
||||
Else
|
||||
ListaNCDesc.Clear()
|
||||
End If
|
||||
Next
|
||||
|
||||
LblDescuentosRNC.Text = TotalRemNCAplicado.FormatoNumero
|
||||
LblTotalNC.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado).FormatoNumero
|
||||
If ListaNCBonificacion Is Nothing Then
|
||||
ListaNCBonificacion = New List(Of Modelos.Factura)
|
||||
Else
|
||||
ListaNCBonificacion.Clear()
|
||||
End If
|
||||
|
||||
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
|
||||
Dim TotalRemNCAplicado As Decimal = 0
|
||||
For Each GvRow As GridViewRow In GvDescNCCargos.Rows
|
||||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||||
If GvRow.FCCheckBox("ChkAplicar").Checked Then
|
||||
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
|
||||
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
|
||||
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
|
||||
|
||||
If RemNC.TotalRemNCAplicado <= 0 Then
|
||||
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCDesc.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ListaNCDesc.Add(RemNC)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim LimiteUsados As Decimal = LblSaldoMaximoUsados.Text.Trim().ToDecimal()
|
||||
|
||||
'VERIFICA EL LIMITE DE LOS USADOS
|
||||
If TotalRemNCAplicado > LimiteUsados Then
|
||||
Alert($"La suma de las remisiones de nota de crédito de tipo 'Cargo' no debe superar el total de Usados.<br/>Total RNC: {TotalRemNCAplicado:N2}.<br/>Total Usados: {LimiteUsados:N2}", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCDesc.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
For Each GvRow As GridViewRow In GvDescNCBonificaciones.Rows
|
||||
If GvRow.RowType = DataControlRowType.DataRow Then
|
||||
If GvRow.FCCheckBox("ChkAplicar").Checked Then
|
||||
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
|
||||
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
|
||||
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero()
|
||||
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
|
||||
|
||||
If RemNC.TotalRemNCAplicado <= 0 Then
|
||||
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCBonificacion.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ListaNCBonificacion.Add(RemNC)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim LimiteBonficaciones As Decimal = LblSaldoMaximoBonificacion.Text.Trim().ToDecimal()
|
||||
|
||||
'VERIFICA EL LIMITE DE LOS USADOS
|
||||
If ListaNCBonificacion.Sum(Function(x) x.TotalRemNCAplicado) > LimiteBonficaciones Then
|
||||
Alert($"La suma de las remisiones de nota de crédito de tipo 'Cargo' no debe superar el total de Usados.<br/>Total RNC: {TotalRemNCAplicado:N2}.<br/>Total Usados: {LimiteUsados:N2}", TipoMensaje.MsgAdvertencia)
|
||||
ListaNCDesc.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
HdnTotalRNC.Value = TotalRemNCAplicado.ToString()
|
||||
LblDescuentosRNC.Text = TotalRemNCAplicado.FormatoNumero
|
||||
LblTotalNC.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado).FormatoNumero
|
||||
|
||||
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
|
||||
|
||||
AplicarNC(CvePS, True)
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió un error al aplicar remisiones de nota de crédito", ex)
|
||||
End Try
|
||||
|
||||
AplicarNC(CvePS, True)
|
||||
|
||||
UpPS.Update()
|
||||
|
||||
@@ -27321,4 +27390,11 @@ Partial Class Ventas
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
Partial Class VentasBonificaciones
|
||||
Public CveVentaRNCCargo As Integer = -1
|
||||
Public CveVentaBonificacion As Integer = -1
|
||||
Public ImporteBonificacion As Decimal = 0
|
||||
Public IVABonificacion As Decimal = 0
|
||||
End Class
|
||||
End Class
|
||||
Reference in New Issue
Block a user