Generar nuevo modal solo para las RNC, que son de tipo devolución, para simple selección y generación
This commit is contained in:
@@ -9403,6 +9403,15 @@ Partial Class Ventas
|
||||
ObjFactura.CveVentaPadre = DtVentasNC.Rows(0)("CveVenta").ToString().ToEntero()
|
||||
ObjFactura.SerieFolioPadre = DtVentasNC.Rows(0)("FolioFiscal").ToString()
|
||||
End If
|
||||
|
||||
If DdlTipoComprobante.SelectedValue = "Dev" AndAlso ListaRemisionesNC IsNot Nothing AndAlso ListaRemisionesNC.Count > 0 Then
|
||||
Dim ObjRNC = ListaRemisionesNC.FirstOrDefault
|
||||
If ObjRNC IsNot Nothing Then
|
||||
ObjFactura.CveVentaPadre = ObjRNC.CveVentaPadre
|
||||
ObjFactura.SerieFolioPadre = ObjRNC.SerieFolioPadre
|
||||
End If
|
||||
End If
|
||||
|
||||
ObjFactura.CveVendedor = DdlVendedor.SelectedValue.ToEntero()
|
||||
If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then
|
||||
DdlVendedor.Enabled = False
|
||||
@@ -24798,6 +24807,11 @@ Partial Class Ventas
|
||||
AplicaNCMasiva = False
|
||||
AplicaNC = False
|
||||
LBNotaCredito.Visible = True
|
||||
|
||||
If UsuarioActual.CveUsuario = 100 Then
|
||||
LnkAplicarRNCDevolucion.Visible = True
|
||||
End If
|
||||
|
||||
'LkNotaCredito.Visible = False
|
||||
|
||||
TxtNCPorcentaje.Attributes.Add("onkeyup", "CalculaImporteNC();")
|
||||
@@ -24848,6 +24862,9 @@ Partial Class Ventas
|
||||
|
||||
AplicaNCMasiva = True
|
||||
LBNotaCredito.Visible = True
|
||||
If UsuarioActual.CveUsuario = 100 Then
|
||||
LnkAplicarRNCDevolucion.Visible = True
|
||||
End If
|
||||
'LkNotaCredito.Visible = False
|
||||
DivGvCxC.Visible = True
|
||||
CargaCxC()
|
||||
@@ -25391,6 +25408,12 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub GvRNCDevoluciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRNCDevoluciones.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCBonChkDesc({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);")
|
||||
e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCBonChkDesc({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub GvDescNCBonificaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCBonificaciones.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
@@ -25516,26 +25539,31 @@ Partial Class Ventas
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional AplicaNuevoDocumento As Boolean = False, Optional AplicoNCFacturaActual As Boolean = False)
|
||||
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional AplicaNuevoDocumento As Boolean = False, Optional AplicoNCFacturaActual As Boolean = False, Optional TipoDoctoNC As String = "Egs")
|
||||
|
||||
Try
|
||||
Me.AplicaDocumentoNuevoNC = AplicaNuevoDocumento
|
||||
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)
|
||||
Exit Sub
|
||||
Else
|
||||
'VALIDA CLAVES SAT
|
||||
If DrPS("SATClavePS").ToString() = "" Then
|
||||
Alert($"El concepto <b>{DrPS("Codigo").ToString()}-{DrPS("PS").ToString()}</b> no cuenta con producto SAT. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
If DrPS("SATClaveUnidadMedida").ToString() = "" Then
|
||||
Alert($"El concepto <b>{DrPS("Codigo").ToString()}-{DrPS("PS").ToString()}</b> no cuenta con Unidad Medida SAT. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
Dim DrPS As DataRow = Nothing
|
||||
|
||||
If CvePS > 0 AndAlso TipoDoctoNC = "Egs" Then
|
||||
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)
|
||||
Exit Sub
|
||||
Else
|
||||
'VALIDA CLAVES SAT
|
||||
If DrPS("SATClavePS").ToString() = "" Then
|
||||
Alert($"El concepto <b>{DrPS("Codigo").ToString()}-{DrPS("PS").ToString()}</b> no cuenta con producto SAT. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
If DrPS("SATClaveUnidadMedida").ToString() = "" Then
|
||||
Alert($"El concepto <b>{DrPS("Codigo").ToString()}-{DrPS("PS").ToString()}</b> no cuenta con Unidad Medida SAT. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If Not AplicaImpuestosLocales Then
|
||||
If TmpDTImpuestos IsNot Nothing Then
|
||||
TmpDTImpuestos.Rows.Clear()
|
||||
@@ -25737,7 +25765,7 @@ Partial Class Ventas
|
||||
Else
|
||||
If DdlTipoComprobante.SelectedValue = "Ant" Then CveAnticipo = CveVenta
|
||||
|
||||
DdlTipoComprobante.SelectedValueExist("Egs")
|
||||
DdlTipoComprobante.SelectedValueExist(TipoDoctoNC)
|
||||
'verifica el total de multiples facturas
|
||||
Dim Acumulado12 As Decimal = 0
|
||||
Dim UltimoRenglon As Integer = 1
|
||||
@@ -25768,7 +25796,10 @@ Partial Class Ventas
|
||||
CrearDTNCBonificacion(ListaRemisionesNC, DtImpuestosBonificacion, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
|
||||
End If
|
||||
|
||||
ElseIf TipoDoctoNC = "Dev" Then
|
||||
CrearDTNCDevolucion(ListaRemisionesNC, TmpDT, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
|
||||
Else
|
||||
|
||||
For Each Dr As DataRow In DtImpuestos.Rows
|
||||
Acumulado12 += Dr("ImportePU").ToString().ToDecimal.RoundSQL + Dr("ImporteIVA").ToString().ToDecimal.RoundSQL + Dr("ImporteIEPS").ToString().ToDecimal
|
||||
If UltimoRenglon = DtImpuestos.Rows.Count Then
|
||||
@@ -25795,7 +25826,16 @@ Partial Class Ventas
|
||||
CalculaTotalesVenta(RecalculaImpuestosLocales:=AplicaImpuestosLocales)
|
||||
|
||||
TrTipoRelacion.Visible = True
|
||||
DdlTiposRelacion.SelectedValueExist("1")
|
||||
If TipoDoctoNC = "Egs" Then
|
||||
DdlTiposRelacion.SelectedValueExist("1")
|
||||
ElseIf TipoDoctoNC = "Dev" Then
|
||||
If DdlTipoComprobante.Items.FindByValue("Dev") Is Nothing Then
|
||||
DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev"))
|
||||
End If
|
||||
DdlTipoComprobante.SelectedValueExist("Dev")
|
||||
DdlTiposRelacion.SelectedValueExist("3")
|
||||
End If
|
||||
|
||||
DdlSubProyectoDatos.Enabled = False
|
||||
|
||||
'condicióon, en la que se verifica que el importe total de aplicación de la nota de crédito sea igual al del total de la nota de crédito, ej. saldo de la factura 1000.01 y la nota de crédito se generó po 1000.00
|
||||
@@ -25804,6 +25844,7 @@ Partial Class Ventas
|
||||
If TT > TxtTotal.Text.ToDecimal Then TT = TxtTotal.Text.ToDecimal
|
||||
CargaNCDT(CveVenta, TT)
|
||||
End If
|
||||
|
||||
'verifica el tipo de cambio que se actualice
|
||||
If DdlMoneda.SelectedValue <> "1" Then
|
||||
TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString()
|
||||
@@ -25812,6 +25853,7 @@ Partial Class Ventas
|
||||
UpPS.Update()
|
||||
|
||||
LBNotaCredito.Visible = False
|
||||
LnkAplicarRNCDevolucion.Visible = False
|
||||
CambiaTipoDocto()
|
||||
|
||||
End If
|
||||
@@ -26160,6 +26202,88 @@ Partial Class Ventas
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CrearDTNCDevolucion(ListaNC As List(Of Modelos.Factura), ByRef TmpDTCargo As DataTable, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String)
|
||||
For Each RNC In ListaNC
|
||||
Dim UltimoRenglonRNC As Integer = 1
|
||||
Dim TotalAcumuladoRNC As Decimal = 0
|
||||
Dim Terminar As Boolean = False
|
||||
|
||||
For Each RowRNC As DataRow In RNC.DtDetalle.FiltraParametros("", Orderby:="PU").Rows
|
||||
|
||||
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=RowRNC("CvePS").ToString().ToEntero()).FiltroPrimero("")
|
||||
|
||||
Dim Cantidad As Decimal = RowRNC("Cantidad").ToString().ToDecimal()
|
||||
|
||||
Dim CvePSCargo As Integer = RowRNC("CvePS").ToString().ToEntero()
|
||||
|
||||
Dim ImportePU = RowRNC("PU").ToString().ToDecimal
|
||||
|
||||
Dim Obs As String = ""
|
||||
|
||||
Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU)
|
||||
|
||||
Dim ImporteIVA = (TotalCalculableImpuestos * RowRNC("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2)
|
||||
Dim ImporteIEPS = (TotalCalculableImpuestos * RowRNC("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2)
|
||||
Dim ImporteRetIVA = (TotalCalculableImpuestos * RowRNC("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2)
|
||||
Dim ImporteRetISR = (TotalCalculableImpuestos * RowRNC("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2)
|
||||
Dim ImporteTotal = TotalCalculableImpuestos
|
||||
|
||||
TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR).RoundSQL
|
||||
|
||||
'SI EL IMPORTE ES MAYOR REALIZA EL AJUSTE
|
||||
If TotalAcumuladoRNC > RNC.TotalRemNCAplicado Then
|
||||
Terminar = True
|
||||
'RESTA LO SUMANDO DEL ACUMULADO
|
||||
TotalAcumuladoRNC -= (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR)
|
||||
|
||||
Dim Diferencia As Decimal = RNC.TotalRemNCAplicado - TotalAcumuladoRNC
|
||||
|
||||
Dim TotalPartida As Decimal = (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR)
|
||||
|
||||
Dim PorcentajePorAplicar As Decimal = (Diferencia / TotalPartida)
|
||||
|
||||
Cantidad = Cantidad * PorcentajePorAplicar
|
||||
|
||||
TotalCalculableImpuestos = (Cantidad * ImportePU)
|
||||
ImporteIVA = (TotalCalculableImpuestos * RowRNC("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2)
|
||||
ImporteIEPS = (TotalCalculableImpuestos * RowRNC("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2)
|
||||
ImporteRetIVA = (TotalCalculableImpuestos * RowRNC("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2)
|
||||
ImporteRetISR = (TotalCalculableImpuestos * RowRNC("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2)
|
||||
|
||||
ImporteTotal = TotalCalculableImpuestos
|
||||
|
||||
TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR).RoundSQL
|
||||
End If
|
||||
|
||||
'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE
|
||||
If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count OrElse Terminar Then
|
||||
Dim Ajuste As Decimal = 0
|
||||
If Math.Abs(RNC.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then
|
||||
Ajuste = RNC.TotalRemNCAplicado - TotalAcumuladoRNC
|
||||
|
||||
If ImporteIVA > 0 Then
|
||||
ImporteIVA += Ajuste
|
||||
ElseIf ImporteIEPS > 0 Then
|
||||
ImporteIEPS += Ajuste
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
UltimoRenglonRNC += 1
|
||||
|
||||
AgregaTempDT(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(),
|
||||
DrPS("CveUM").ToString().ToEntero(), DrPS("UnidadMedida").ToString(), DrPS("CveClasificacion").ToString().ToEntero(), DrPS("Clasificacion").ToString(), CveProyecto, Proyecto, CveSubProyecto, SubProyecto,
|
||||
Obs, Cantidad, ImportePU, RowRNC("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, RowRNC("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA,
|
||||
RowRNC("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, RowRNC("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0, ImporteTotal, "", "", -1, -1,
|
||||
DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowRNC("CveVentaDetalle").ToString().ToEntero())
|
||||
|
||||
If Terminar Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
Next
|
||||
End Sub
|
||||
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal, Optional NCDescuento As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional NivelTotal As Integer = 1, Optional AplicaNCUsado As Boolean = False) As DataTable
|
||||
Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
|
||||
|
||||
@@ -26367,6 +26491,7 @@ Partial Class Ventas
|
||||
HplDownPDF.Visible = False
|
||||
HLSaldarVenta.Visible = False
|
||||
LBNotaCredito.Visible = False
|
||||
LnkAplicarRNCDevolucion.Visible = False
|
||||
LiComplementoPago.Visible = False
|
||||
HlCuentaTerminal.Visible = False
|
||||
LiLnkGuias.Visible = False
|
||||
@@ -26743,6 +26868,7 @@ Partial Class Ventas
|
||||
HplDownPDF.Visible = False
|
||||
HLSaldarVenta.Visible = False
|
||||
LBNotaCredito.Visible = False
|
||||
LnkAplicarRNCDevolucion.Visible = False
|
||||
LiComplementoPago.Visible = False
|
||||
HlCuentaTerminal.Visible = False
|
||||
LiLnkGuias.Visible = False
|
||||
@@ -31150,4 +31276,68 @@ Partial Class Ventas
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
Protected Sub LnkAplicarRNCDevolucion_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim DtNC As DataTable = Nothing
|
||||
|
||||
Dim ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
|
||||
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND TipoRNC = 3 AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
|
||||
End If
|
||||
ObjMovtos.Dispose()
|
||||
|
||||
GvRNCDevoluciones.DataSource = DtNC
|
||||
GvRNCDevoluciones.DataBind()
|
||||
|
||||
UpRNCDevolucion.Update()
|
||||
|
||||
RegistraScript("$('#ModalAplicaRNCDevolucion').modal('show');")
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAplicarRNCDevoluciones_Click(sender As Object, e As EventArgs)
|
||||
Me.AplicaRNCXDetalle = False
|
||||
|
||||
If ListaRemisionesNC Is Nothing Then
|
||||
ListaRemisionesNC = New List(Of Modelos.Factura)
|
||||
Else
|
||||
ListaRemisionesNC.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 GvRNCDevoluciones.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)
|
||||
ListaRemisionesNC.Clear()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
ListaRemisionesNC.Add(RemNC)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
TxtImportesRemisionesNC.Text = TotalRemNCAplicado.FormatoNumero
|
||||
TxtNCImporte.Text = TotalRemNCAplicado.FormatoNumero
|
||||
|
||||
UpModalRemisionesNC.Update()
|
||||
UpAplicarNC.Update()
|
||||
|
||||
AplicarNC(-1, NCDescuento:=False, EsNCAmortizacion:=False, AplicaImpuestosLocales:=True, AplicaNuevoDocumento:=True, AplicoNCFacturaActual:=True, TipoDoctoNC:="Dev")
|
||||
|
||||
RegistraScript("$('#ModalAplicaRNCDevolucion').modal('hide');")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user