--aplicacion de RNC como devolucion de remisiones
This commit is contained in:
@@ -3548,10 +3548,6 @@ Partial Class Ventas
|
||||
End If
|
||||
UpPS.Update()
|
||||
|
||||
If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then
|
||||
DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC"))
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
@@ -5112,11 +5108,23 @@ Partial Class Ventas
|
||||
End If
|
||||
DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero()
|
||||
EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString())
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
|
||||
Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto")))
|
||||
If TienePermiso <> "" Then ' si tiene acceso en el subproyecto
|
||||
'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175)
|
||||
If UsuarioActual.TienePermisoProceso(264) Then
|
||||
InicializaAplicaRNCDevolucion(TmpDT)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Case "RNC"
|
||||
Trsaldo.Visible = True
|
||||
HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta"))
|
||||
HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta"))
|
||||
|
||||
If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then
|
||||
DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC"))
|
||||
End If
|
||||
DdlTipoComprobante.SelectedValueExist("RNC")
|
||||
Case "OP"
|
||||
TdOrdenPago.Visible = True
|
||||
DdlOrdenPago.SelectedValue = DbRowVenta("Num3").ToString()
|
||||
@@ -14904,6 +14912,42 @@ Partial Class Ventas
|
||||
|
||||
Next
|
||||
|
||||
If ObjFactura.AplicaDevolucion AndAlso ObjFactura.TipoDocto = "RNC" AndAlso CveVentaDevolucion > 0 Then
|
||||
Dim importeMovimientoDev As Decimal = TxtTotal.Text.ToDecimal
|
||||
importeMovimientoDev = If(SaldoVentaDevolucion < importeMovimientoDev, SaldoVentaDevolucion, importeMovimientoDev)
|
||||
|
||||
importeMovimiento = importeMovimientoDev * Multiplicador
|
||||
importeMX = importeMovimiento * tipoCambio
|
||||
|
||||
If importeMovimiento <> 0 Then
|
||||
If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, 150, Referencia, Concepto, CveVenta:=CveVentaDevolucion, CveCliente:=ObjFactura.CveCliente, CveVentaAmortizacion:=-1, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveClasificacion:=ObjFactura.DtDetalle.MAX("CveClasificacion").ToEntero(), CveSubProyecto:=ObjFactura.CveSubProyecto, Contabilizable:=Contabilizable) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
|
||||
If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento * -1, importeMX * -1, 277, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=-1, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
|
||||
If Not ErrorPrepoliza AndAlso Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento * -1, importeMX * -1, 278, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, CveVentaAmortizacion:=-1, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), Contabilizable:=False, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
|
||||
If Not ErrorPrepoliza Then
|
||||
Dim CveConceptoPagoNC As Integer = 251
|
||||
If ObjFactura.CveMoneda > 1 Then
|
||||
CveConceptoPagoNC = 301
|
||||
End If
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, True, importeMovimiento, importeMX, CveConceptoPagoNC, Referencia, Concepto, CveVenta:=CveVentaDevolucion, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIE, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=Contabilizable) Then
|
||||
ErrorPrepoliza = True
|
||||
Else
|
||||
ViewState("SeGuardoPrePoliza") = True
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(344) = "1" AndAlso ObjFactura.TipoDocto = "Egs" Then
|
||||
Dim ListaNC As List(Of Modelos.Factura) = Nothing
|
||||
|
||||
@@ -27471,34 +27515,39 @@ Partial Class Ventas
|
||||
|
||||
#Region " APLICAR NOTA DE CREDITO "
|
||||
Private Sub InicializaAplicarNC()
|
||||
'If Not UsuarioActual.CveUsuario = 100 Then
|
||||
' If Not UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119) Then
|
||||
' Exit Sub
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If CveVenta <= 0 Or Not DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Or Not HplSaldoAuxiliar.Text.ToDouble > 0 Then
|
||||
''If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then LkNotaCredito.Visible = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'sino tiene el permiso de peude generar NC
|
||||
If Not UsuarioActual.TienePermisoProceso(175) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DeshabilitarAplicarNotaDeCredito(LblRFC.Text) Then
|
||||
'SI NO ES VENTA EXISTENTE NO DEBE ENTRAR ESTE PROCESO
|
||||
If CveVenta <= 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
AplicaNCMasiva = False
|
||||
AplicaNC = False
|
||||
LBNotaCredito.Visible = True
|
||||
|
||||
If UsuarioActual.CveUsuario = 100 Then
|
||||
LnkAplicarRNCDevolucion.Visible = True
|
||||
'SOLO APLICA PARA INGRESOS O ANTICIPOS
|
||||
If (Not DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant")) Then
|
||||
''If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then LkNotaCredito.Visible = False
|
||||
LBNotaCredito.Visible = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'sino tiene el permiso de peude generar NC
|
||||
If Not UsuarioActual.TienePermisoProceso(175) Then
|
||||
LBNotaCredito.Visible = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then
|
||||
LBNotaCredito.Visible = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DeshabilitarAplicarNotaDeCredito(LblRFC.Text) Then
|
||||
LBNotaCredito.Visible = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
LBNotaCredito.Visible = True
|
||||
|
||||
'LkNotaCredito.Visible = False
|
||||
|
||||
TxtNCPorcentaje.Attributes.Add("onkeyup", "CalculaImporteNC();")
|
||||
@@ -27552,9 +27601,7 @@ Partial Class Ventas
|
||||
|
||||
AplicaNCMasiva = True
|
||||
LBNotaCredito.Visible = True
|
||||
If UsuarioActual.CveUsuario = 100 Then
|
||||
LnkAplicarRNCDevolucion.Visible = True
|
||||
End If
|
||||
|
||||
'LkNotaCredito.Visible = False
|
||||
TxtNCPorcentaje.Attributes.Add("onkeyup", "CalculaImporteNCMasivo();")
|
||||
TxtNCImporte.Text = "0.00"
|
||||
@@ -30003,6 +30050,45 @@ Partial Class Ventas
|
||||
|
||||
UpDevolucion.Update()
|
||||
|
||||
End Sub
|
||||
Private Sub InicializaAplicaRNCDevolucion(DtDetalle As DataTable)
|
||||
|
||||
'sino tiene el permiso no puede generar Devolucion
|
||||
If Not UsuarioActual.TienePermisoProceso(264) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
LnkAplicarRNCDevolucion.Visible = True
|
||||
|
||||
Dim SeEsconde As Boolean = False
|
||||
|
||||
If DtDetalle IsNot Nothing AndAlso DtDetalle.Rows.Count > 0 Then
|
||||
If Not DtDetalle.SUM("CantSur").ToString().ToDecimal > 0 Then SeEsconde = True
|
||||
'NO MOSTRAR LOS PRODUCTOS CON LA CLASIFICACION DE USADOS
|
||||
GvAplicaRNCDevolucion.DataSource = DtDetalle.FiltraParametros("CantRes > 0 AND CveClasificacion <> 20519")
|
||||
End If
|
||||
|
||||
|
||||
'activo el permiso para registrar el importe diferente a la devolución
|
||||
'GvAplicaRNCDevolucion.Columns(9).Visible = UsuarioActual.TienePermisoProceso(253)
|
||||
|
||||
'MODALIDAD CENTRO COSTOS
|
||||
If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then
|
||||
GvAplicaRNCDevolucion.Columns(7).HeaderText = "Sucursal"
|
||||
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then
|
||||
GvAplicaRNCDevolucion.Columns(7).HeaderText = "Proyecto"
|
||||
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then
|
||||
GvAplicaRNCDevolucion.Columns(7).HeaderText = "Sucursal/Proyecto"
|
||||
ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then
|
||||
GvAplicaRNCDevolucion.Columns(7).HeaderText = "Proyecto/Sucursal"
|
||||
End If
|
||||
|
||||
If SeEsconde Then GvAplicaRNCDevolucion.Columns(1).Visible = False : GvAplicaRNCDevolucion.Columns(2).Visible = False : GvAplicaRNCDevolucion.Columns(3).Visible = False
|
||||
|
||||
GvAplicaRNCDevolucion.DataBind()
|
||||
|
||||
UpAplicaRNCDevolucion.Update()
|
||||
|
||||
End Sub
|
||||
Protected Sub BtnCalcularPenalizacion_Click(sender As Object, e As EventArgs)
|
||||
Dim PorcentajePenalizacion As Decimal = (TxtPorPenalizacion.Text.ToDecimal() / 100D)
|
||||
@@ -35019,20 +35105,51 @@ Partial Class Ventas
|
||||
|
||||
Protected Sub LnkAplicarRNCDevolucion_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim DtNC As DataTable = Nothing
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
|
||||
Dim SaldoAlmacen As Decimal = 0
|
||||
|
||||
Dim ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) Then
|
||||
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND TipoRNC = 3 AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
|
||||
Dim PermiteCancelar As Boolean = True
|
||||
Using ObjVentas As New ClsVentas
|
||||
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa, VerificaAlmacen:=True) Then
|
||||
If ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
Dim RowVenta As DataRow = ObjVentas.DtResultados.Rows(0)
|
||||
SaldoAlmacen = RowVenta("SaldoAlmacen").ToString().ToDecimal()
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
|
||||
Dim PuedeAplicarDevolucion As Boolean = False
|
||||
|
||||
If SaldoAlmacen > 0 Then
|
||||
If DevolucionAlmacen = 0 Then
|
||||
PuedeAplicarDevolucion = True
|
||||
ElseIf DevolucionAlmacen.Contiene(1, 2) Then
|
||||
Alert("No se puede aplicar una devolución sobre el documento actual", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
ElseIf SaldoAlmacen <= 0 Then
|
||||
Alert("No se puede aplicar una devolución sobre el documento actual", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
If PuedeAplicarDevolucion Then
|
||||
RegistraScript("$('#DivAplicaRNCDevolucion').modal('show');")
|
||||
End If
|
||||
Else
|
||||
Dim DtNC As DataTable = Nothing
|
||||
|
||||
Dim ObjMovtos As New ClsMovimientos()
|
||||
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) 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 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)
|
||||
@@ -37512,5 +37629,88 @@ Partial Class Ventas
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub GvAplicaRNCDevolucion_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.FCTextBox("TxtCantidadAplicaDevolucion").Attributes.Add("onkeyup", $"LimitaCantidadAplicaDev({e.Row.DBCampo("CantRes").ToDecimal}, this);")
|
||||
If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Or UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then
|
||||
e.Row.FCLabel("LblProyecto").Text = e.Row.FCLabel("LblSubProyecto").Text
|
||||
e.Row.FCLabel("LblProyecto").Style.Clear()
|
||||
e.Row.FCLabel("LblSubProyecto").Text = ""
|
||||
'e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);")
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAplicaRNCDevolucion_Click(sender As Object, e As EventArgs)
|
||||
|
||||
Dim Selecciono As Boolean = False
|
||||
For Each Gv As GridViewRow In GvAplicaRNCDevolucion.Rows
|
||||
If Gv.FCCheckBox("Chk").Checked And Gv.FCTextBox("TxtCantidadAplicaDevolucion").Text.ToDouble > 0 Then
|
||||
Selecciono = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
If Not Selecciono Then
|
||||
Alert("Tiene que seleccionar al menos un concepto y este dege tener una cantidad mayor a 0. Por favor verifique y vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then
|
||||
DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC"))
|
||||
End If
|
||||
|
||||
DdlTipoComprobante.SelectedValueExist("RNC")
|
||||
|
||||
TmpDT.Clear()
|
||||
For Each Gv As GridViewRow In GvAplicaRNCDevolucion.Rows
|
||||
If Gv.FCCheckBox("Chk").Checked And Gv.FCTextBox("TxtCantidadAplicaDevolucion").Text.ToDecimal > 0 Then
|
||||
Dim Cantidad As Decimal = Gv.FCTextBox("TxtCantidadAplicaDevolucion").Text.ToDecimal
|
||||
Dim Descuento As Decimal = Cantidad * Gv.DataKey("Descuento").ToString().ToDecimal / Gv.DataKey("Cantidad").ToString().ToDecimal
|
||||
Dim PU As Decimal = Gv.DataKey("PU").ToDecimal
|
||||
Dim Total As Decimal = (Cantidad * PU)
|
||||
Dim TotalImpuestos As Decimal = (Cantidad * PU) - Descuento
|
||||
Dim TotalCalculableImpuestosIVA As Decimal = TotalImpuestos * (1 + Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal)
|
||||
Dim ImporteIVA As Decimal = TotalCalculableImpuestosIVA * Gv.DataKey("PorcentajeIVA").ToString().ToDecimal
|
||||
Dim ImporteRetIVA As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetIVA").ToString().ToDecimal
|
||||
Dim ImporteRetISR As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeRetISR").ToString().ToDecimal
|
||||
Dim ImporteIEPS As Decimal = TotalImpuestos * Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal
|
||||
Dim CodigoObjetoImpuesto As String = Gv.DataKey("CodigoObjetoImpuesto")
|
||||
|
||||
AgregaTempDT(TmpDT, Gv.DataKey("CvePS").ToString().ToEntero(), Gv.DataKey("PS").ToString(), Gv.DataKey("Codigo").ToString(), Gv.DataKey("CodigoPS").ToString(),
|
||||
Gv.DataKey("CveTipoPS").ToString().ToEntero(), Gv.DataKey("CveTipoInvPS").ToString().ToEntero(),
|
||||
Gv.DataKey("CveUM").ToString().ToEntero(), Gv.DataKey("UM").ToString(), Gv.DataKey("CveClasificacion").ToString().ToEntero(),
|
||||
Gv.DataKey("Clasificacion").ToString(), Gv.DataKey("CveProyecto").ToString().ToEntero(), Gv.DataKey("Proyecto").ToString(),
|
||||
Gv.DataKey("CveSubProyecto").ToString().ToEntero(), Gv.DataKey("SubProyecto").ToString(),
|
||||
Gv.DataKey("Obs").ToString(), Cantidad, PU, Gv.DataKey("PorcentajeIVA").ToString().ToDecimal, ImporteIVA,
|
||||
Gv.DataKey("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA,
|
||||
Gv.DataKey("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, Gv.DataKey("PorcentajeIEPS").ToString().ToDecimal,
|
||||
ImporteIEPS, -1, Descuento, Total, "", "", -1, -1,
|
||||
Gv.DataKey("SATClaveProdServ").ToString(), Gv.DataKey("SATClaveUM").ToString(), -1, Gv.DataKey("CveVentaDetalle").ToString().ToEntero(), -1, -1, -1, -1, Gv.DataKey("CveTamaño").ToEntero(), CodigoObjetoImpuesto:=CodigoObjetoImpuesto)
|
||||
End If
|
||||
Next
|
||||
|
||||
BtnsFacturar.Visible = False
|
||||
BtnEditarRemision.Visible = False
|
||||
|
||||
LimpiaDocumentoDEV()
|
||||
CambiaTipoDocto()
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
|
||||
If TxtAtencionA.Text.Trim.Length = 0 Then
|
||||
TxtAtencionA.Enabled = True
|
||||
End If
|
||||
End If
|
||||
|
||||
CalculaTotalesVenta()
|
||||
|
||||
UpParametros.Update()
|
||||
|
||||
AplicaDevolucion = True
|
||||
CveVentaDevolucion = Me.CveVenta
|
||||
SaldoVentaDevolucion = HplSaldoAuxiliar.Text.ToDecimal
|
||||
|
||||
RegistraScript("$('#DivAplicaRNCDevolucion').modal('hide')")
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user