Descuentos por RNC

This commit is contained in:
2019-11-15 19:22:23 -07:00
parent 1e0f7a2255
commit f5b6f64923
4 changed files with 1665 additions and 1305 deletions

View File

@@ -83,7 +83,7 @@
<div style=""> <div style="">
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False" <asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveSubProyecto,SubProyecto,IdSegNeg,Estatus,Serie,IVA,Calle,NoExt,NoInt,Colonia,Localidad,Municipio,Estado,Pais,CP,CveProyecto,TipoSucursal,EsSucursal, DataKeyNames="CveSubProyecto,SubProyecto,IdSegNeg,Estatus,Serie,IVA,Calle,NoExt,NoInt,Colonia,Localidad,Municipio,Estado,Pais,CP,CveProyecto,TipoSucursal,EsSucursal,
CvePais,CveEstado,CveMunicipio,CveColonia,AplicaComercioExterior,CvePrecioLista,Correo,Telefono,HorarioVerano,HorarioInvierno" CvePais,CveEstado,CveMunicipio,CveColonia,AplicaComercioExterior,CvePrecioLista,Correo,Telefono,UTCOffsetVerano,UTCOffsetInvierno"
EmptyDataText="No se encontraron SubProyectos" ShowHeader="true" CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn" data-sort="true" BorderWidth="1" BorderColor="#D3D3D3" GridLines="None"> EmptyDataText="No se encontraron SubProyectos" ShowHeader="true" CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn" data-sort="true" BorderWidth="1" BorderColor="#D3D3D3" GridLines="None">
<Columns> <Columns>
<asp:BoundField DataField="SubProyecto" HeaderText="Centro de costo" /> <asp:BoundField DataField="SubProyecto" HeaderText="Centro de costo" />

View File

@@ -284,8 +284,8 @@ Partial Class CatSubProyectos
DdlPrecioLista.SelectedValueExist(GvRow.DataKey("CvePrecioLista")) DdlPrecioLista.SelectedValueExist(GvRow.DataKey("CvePrecioLista"))
TxtCorreo.Text = (GvRow.DataKey("Correo")) TxtCorreo.Text = (GvRow.DataKey("Correo"))
TxtTelefono.Text = (GvRow.DataKey("Telefono")) TxtTelefono.Text = (GvRow.DataKey("Telefono"))
TxtHorarioVerano.Text = (GvRow.DataKey("HorarioVerano")) TxtHorarioVerano.Text = (GvRow.DataKey("UTCOffsetVerano"))
TxtHorarioInvierno.Text = (GvRow.DataKey("HorarioInvierno")) TxtHorarioInvierno.Text = (GvRow.DataKey("UTCOffsetInvierno"))
'COMERCIO EXTERIOR 'COMERCIO EXTERIOR
ChkAplicaComercioExterior.Checked = If(GvRow.DataKey("AplicaComercioExterior").ToString = "True", True, False) ChkAplicaComercioExterior.Checked = If(GvRow.DataKey("AplicaComercioExterior").ToString = "True", True, False)
DdlPais.SelectedValueExist(GvRow.DataKey("CvePais")) DdlPais.SelectedValueExist(GvRow.DataKey("CvePais"))

View File

@@ -1279,11 +1279,29 @@
</div> </div>
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
</div> </div>
</div> </div>
<div class="col-md-6 ">
<div class="row">
<div class="col-md-6">
<table id="TbDescuentosRNC" border="0" rules="none" class="well TextTab" style="float: right;" runat="server" visible="false">
<tr align="right">
<td style="border: 1px none white"><b>Descuentos. RNC.:</b></td>
<td>
<asp:Label ID="LblDescuentosRNC" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00" Width="78px"></asp:Label></td>
<td align="right">&nbsp;<asp:LinkButton ID="LnkDescuentosRNC" runat="server" OnClick="LnkDescuentosRNC_Click" Text="<i class='fa fa-tag fa-lg font-green'></i>" AlternateText="Aplicacion de RNC" Style="cursor: pointer;" />
</td>
</tr>
<tr align="right">
<td style="border: 1px none white"><b>Total NC.:</b></td>
<td>
<asp:Label ID="LblTotalNC" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00" Width="78px"></asp:Label></td>
<td align="right">&nbsp;
</td>
</tr>
</table>
</div>
<div class="col-md-6"> <div class="col-md-6">
<table border="0" rules="none" class="well TextTab" style="float: right;"> <table border="0" rules="none" class="well TextTab" style="float: right;">
<tr align="right"> <tr align="right">
@@ -1469,6 +1487,8 @@
</table> </table>
</div> </div>
</div> </div>
</div>
</div>
</ContentTemplate> </ContentTemplate>
@@ -6329,6 +6349,63 @@
</asp:UpdatePanel> </asp:UpdatePanel>
</div> </div>
</div> </div>
<%--APLICAR REMISIONES DE NC--%>
<div id="ModalAplicarDescuentoNC" class="modal ADS fade" role="dialog">
<asp:UpdatePanel ID="UpDescNC" class="modal-dialog rowpadding" tabindex="-1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Aplicar Remisiones de Nota de Crédito</h4>
</div>
<div class="modal-body">
<div class="row" style="margin-right: 10px; margin-top: 18px;" align="right">
<input type="text" id="TxtBusquedaDescC" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaDescC','{0}')", GvDescNC.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaDescC','{0}')", GvDescNC.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
<div class="row" style="max-height: 10px">
<div class="col-md-12" style="height: 440px; overflow: auto">
<asp:GridView ID="GvDescNC" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveVenta" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ChkAplicar" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataNavigateUrlFields="CveVenta" Target="_blank" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataTextField="SerieFolio" HeaderText="Folio" ItemStyle-Width="150px" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Fecha" DataField="Fecha" DataFormatString="{0:d}" ItemStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:Literal ID="LtlTotal" runat="server" Text='<%# Eval("Original", "{0:N2}") %>'></asp:Literal>
<asp:Literal ID="LtlAbrev" runat="server" Text='<%# Eval("Abreviatura") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Saldo" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:Literal ID="LtlSaldo" runat="server" Text='<%# Eval("Saldo", "{0:N2}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TxtImporte" CssClass="myvalue" runat="server" Width="75px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
<div class="modal-footer">
<button id="CancelarAplicarDescNC" type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<asp:Button Text="Aplicar Descuento" ID="BtnAplicarDesc" OnClick="BtnAplicarDesc_Click" CssClass="btn btn-primary" runat="server" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content> </asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server"> <asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
<script src="/Metronic/assets/global/scripts/jquery-sortable.js"></script> <script src="/Metronic/assets/global/scripts/jquery-sortable.js"></script>

View File

@@ -85,6 +85,14 @@ Partial Class Ventas
End Property End Property
'Local 'Local
Private Property DtPorcentajeMarcas As DataTable
Get
Return If(IsNothing(ViewState("DtPorcentajeMarcas")), Nothing, CType(ViewState("DtPorcentajeMarcas"), DataTable))
End Get
Set(value As DataTable)
ViewState("DtPorcentajeMarcas") = value
End Set
End Property
Private Property TmpDT As DataTable Private Property TmpDT As DataTable
Get Get
Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable)) Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable))
@@ -265,6 +273,14 @@ Partial Class Ventas
ViewState("ListaRemisionesNC") = value ViewState("ListaRemisionesNC") = value
End Set End Set
End Property End Property
Private Property ListaNCDesc As List(Of Modelos.Factura)
Get
Return If(IsNothing(ViewState("ListaNCDesc")), Nothing, CType(ViewState("ListaNCDesc"), List(Of Modelos.Factura)))
End Get
Set(value As List(Of Modelos.Factura))
ViewState("ListaNCDesc") = value
End Set
End Property
Private Property Pedidos2Lista As List(Of Integer) Private Property Pedidos2Lista As List(Of Integer)
Get Get
Return If(IsNothing(ViewState("Pedidos2Lista")), Nothing, CType(ViewState("Pedidos2Lista"), List(Of Integer))) Return If(IsNothing(ViewState("Pedidos2Lista")), Nothing, CType(ViewState("Pedidos2Lista"), List(Of Integer)))
@@ -2463,7 +2479,7 @@ Partial Class Ventas
InicializaAplicarNC() InicializaAplicarNC()
If CveCliente > 0 Then If CveCliente > 0 Then
CargaRestriccionesCreditoCliente() CargaRestriccionesCreditoCliente(CveVenta:=Me.CveVenta)
End If End If
If Not CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(403).ToString = "1" Then If Not CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(403).ToString = "1" Then
@@ -2512,6 +2528,11 @@ Partial Class Ventas
End If End If
TxtFecha.Enabled = True TxtFecha.Enabled = True
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
TbDescuentosRNC.Visible = True
End If
CargaPorcentajeMarcas()
End Sub End Sub
Private Sub ConfiguraEmpresa() Private Sub ConfiguraEmpresa()
@@ -4947,7 +4968,7 @@ Partial Class Ventas
TrVistaPrevia.Visible = True TrVistaPrevia.Visible = True
If Not (ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then If Not (ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then
CargaRestriccionesCreditoCliente(True) CargaRestriccionesCreditoCliente(True, Me.CveVenta)
End If End If
@@ -5001,7 +5022,7 @@ Partial Class Ventas
End Sub End Sub
Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False) Private Sub CargaRestriccionesCreditoCliente(Optional Alertas As Boolean = False, Optional CveVenta As Integer = -1)
Dim ObjCliente As New ClsClientes() Dim ObjCliente As New ClsClientes()
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then If ObjCliente.DtResultados.Rows.Count > 0 Then
@@ -6120,7 +6141,11 @@ Partial Class Ventas
#Region " EMITIR IMPRIMIR - GUARDAR " #Region " EMITIR IMPRIMIR - GUARDAR "
Protected Sub BtnEmitirImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitirImprimir.Click Protected Sub BtnEmitirImprimir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnEmitirImprimir.Click
Try
EmitirImprimir() EmitirImprimir()
Catch ex As Exception
OnError(ex.ToString(), ex)
End Try
End Sub End Sub
Private Sub EmitirImprimir() Private Sub EmitirImprimir()
@@ -6525,7 +6550,6 @@ Partial Class Ventas
' Exit Sub ' Exit Sub
'End If 'End If
If ObjFactura.CveCliente > 0 Or CveEmpresaCRM > 0 Then If ObjFactura.CveCliente > 0 Or CveEmpresaCRM > 0 Then
If TmpDT.Rows.Count > 0 Then If TmpDT.Rows.Count > 0 Then
@@ -6597,7 +6621,8 @@ Partial Class Ventas
EsNCAmortizacion = True EsNCAmortizacion = True
End If End If
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS, ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion) GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjFactura, TmpDT, ObjFactura.CveNCaVincular, ObjContPaq, ObjBancos, ObjOS,
ObjEventos, ObjCGame, ObjClientes, EsNCAmortizacion:=EsNCAmortizacion)
'SI ES REFACTURACION 'SI ES REFACTURACION
Dim ObjNC As List(Of Object) = Nothing Dim ObjNC As List(Of Object) = Nothing
@@ -6620,30 +6645,21 @@ Partial Class Ventas
End If End If
End If End If
'SI ES AMORTIZACION 3.3
'SI ES amortizacion 3.3
Dim Obj2 As New List(Of Object) Dim Obj2 As New List(Of Object)
Dim NCDescuento As Boolean = (ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0)
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
' cambiar la condicion para saber si hay seleccionado ' cambiar la condicion para saber si hay seleccionado
If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then If (TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2") OrElse NCDescuento Then
If TieneAnticipo Then
CreaObjetosVentaAmortizacion(ObjVentas, FolioFiscalRelacionado, CveAnticipoPadre)
Try Try
If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaDevolucion, ObjBancos, Nothing, Nothing) Then CreaObjetosVentaAmortizacion(ObjVentas, FolioFiscalRelacionado, CveAnticipoPadre, NCDescuento:=NCDescuento)
If RegistrarNCAmortizacion(ObjVentas, ObjConta, ObjInventario, ObjContr, ObjContPaq, ObjFacturaDevolucion, ObjBancos, Nothing,
Nothing, NCDescuento:=NCDescuento) Then
Obj2.Add(ObjFacturaDevolucion) Obj2.Add(ObjFacturaDevolucion)
End If End If
Catch ex As Exception Catch ex As Exception
ErrorList.Add("No se pudo generarse la nota de crédito de amortización") ErrorList.Add("No se pudo generarse la nota de crédito de amortización")
End Try End Try
End If
If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then If Obj2 Is Nothing AndAlso Obj2.Count = 0 Then
ErrorList.Add("No se pudo generarse la nota de crédito de amortización") ErrorList.Add("No se pudo generarse la nota de crédito de amortización")
End If End If
@@ -6820,7 +6836,6 @@ Partial Class Ventas
End Try End Try
Dim SeTimbro As Boolean = False Dim SeTimbro As Boolean = False
Dim SeTimbroNC As Boolean = False Dim SeTimbroNC As Boolean = False
Dim EstatusSMS = 0 Dim EstatusSMS = 0
@@ -7084,7 +7099,8 @@ Partial Class Ventas
End Sub End Sub
Private Sub CreaObjetosVentaAmortizacion(ObjVentas As ClsVentas, FolioFiscalRelacionado As String, CveAnticipoPadre As Integer, Optional CveVentasPadre As Integer = -1) Private Sub CreaObjetosVentaAmortizacion(ObjVentas As ClsVentas, FolioFiscalRelacionado As String, CveAnticipoPadre As Integer,
Optional CveVentasPadre As Integer = -1, Optional NCDescuento As Boolean = False)
ObjFacturaDevolucion = New Modelos.Factura ObjFacturaDevolucion = New Modelos.Factura
ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
@@ -7098,7 +7114,6 @@ Partial Class Ventas
ObjFacturaDevolucion.CveVentaRelacion = ObjVentas.CveVenta ObjFacturaDevolucion.CveVentaRelacion = ObjVentas.CveVenta
End If End If
ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa
ObjFacturaDevolucion.TipoCambio = If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.Trim.ToDecimal) ObjFacturaDevolucion.TipoCambio = If(DdlMoneda.SelectedValue.ToEntero = 1, 1, TxtTipoCambio.Text.Trim.ToDecimal)
ObjFacturaDevolucion.ConvertirPesos = ChkConvertirDoctoPesos.Checked ObjFacturaDevolucion.ConvertirPesos = ChkConvertirDoctoPesos.Checked
@@ -7139,6 +7154,7 @@ Partial Class Ventas
ObjFacturaDevolucion.CveTipoRelacion = DdlTipoRelacionAnticipo.SelectedValue.ToEntero ObjFacturaDevolucion.CveTipoRelacion = DdlTipoRelacionAnticipo.SelectedValue.ToEntero
ObjFacturaDevolucion.TipoRelacion = "07" ObjFacturaDevolucion.TipoRelacion = "07"
Dim Fol As New List(Of String) Dim Fol As New List(Of String)
Fol.Add(FolioFiscalRelacionado) Fol.Add(FolioFiscalRelacionado)
ObjFacturaDevolucion.UUIDRelacionados = Fol ObjFacturaDevolucion.UUIDRelacionados = Fol
@@ -7199,7 +7215,23 @@ Partial Class Ventas
ObjFacturaDevolucion.Det_FechaOrdenCompra = TxtDet_FechaOrdenCompra.Text.Trim ObjFacturaDevolucion.Det_FechaOrdenCompra = TxtDet_FechaOrdenCompra.Text.Trim
ObjFacturaDevolucion.MonedaAbreviatura = "" ObjFacturaDevolucion.MonedaAbreviatura = ""
'Totales, Y se llena TmpDTImpuestos 'DETALLES
If NCDescuento Then
ObjFacturaDevolucion.DtDetalle = CreaDTDetalleNCDescuento()
ObjFacturaDevolucion.SubTotal = ObjFacturaDevolucion.DtDetalle.SUM("Total").ToDecimal()
ObjFacturaDevolucion.Descuento = ObjFacturaDevolucion.DtDetalle.SUM("Descuento").ToDecimal()
ObjFacturaDevolucion.Amortizacion = 0
ObjFacturaDevolucion.IVA = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIVA").ToDecimal()
ObjFacturaDevolucion.RetIVA = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetIVA").ToDecimal()
ObjFacturaDevolucion.RetISR = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetISR").ToDecimal()
ObjFacturaDevolucion.IEPS = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIEPS").ToDecimal()
Dim Total As Decimal = (ObjFacturaDevolucion.SubTotal + ObjFacturaDevolucion.IVA + ObjFacturaDevolucion.IEPS) - (ObjFacturaDevolucion.Descuento + ObjFacturaDevolucion.RetIVA + ObjFacturaDevolucion.RetISR + ObjFacturaDevolucion.Amortizacion)
ObjFacturaDevolucion.Total = Total
Else
ObjFacturaDevolucion.DtDetalle = TmpDT
ObjFacturaDevolucion.SubTotal = TxtSubTotal.Text.ToDecimal ObjFacturaDevolucion.SubTotal = TxtSubTotal.Text.ToDecimal
ObjFacturaDevolucion.Descuento = LblDescuentos.Text.Trim.ToDecimal ObjFacturaDevolucion.Descuento = LblDescuentos.Text.Trim.ToDecimal
ObjFacturaDevolucion.Amortizacion = LblAmortizacion.Text.Trim.ToDecimal ObjFacturaDevolucion.Amortizacion = LblAmortizacion.Text.Trim.ToDecimal
@@ -7208,6 +7240,8 @@ Partial Class Ventas
ObjFacturaDevolucion.RetISR = TxtRetISR.Text.ToDecimal ObjFacturaDevolucion.RetISR = TxtRetISR.Text.ToDecimal
ObjFacturaDevolucion.IEPS = TxtIEPS.Text.ToDecimal ObjFacturaDevolucion.IEPS = TxtIEPS.Text.ToDecimal
ObjFacturaDevolucion.Total = TxtTotal.Text.ToDecimal ObjFacturaDevolucion.Total = TxtTotal.Text.ToDecimal
End If
'Totales, Y se llena TmpDTImpuestos
'ObjFactura.BZDescripcion = TxtBZDescripcion.Text.Trim 'ObjFactura.BZDescripcion = TxtBZDescripcion.Text.Trim
'ObjFactura.BZNombreCorto = TxtBZNombreCorto.Text.Trim 'ObjFactura.BZNombreCorto = TxtBZNombreCorto.Text.Trim
@@ -7255,12 +7289,10 @@ Partial Class Ventas
End If End If
Next Next
If TxtTotal.Text.ToDecimal <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = TxtTotal.Text.ToDecimal : DR("Orden") = 100 : DR("TipoImpuesto") = "0" : TmpDTImpuestos.Rows.Add(DR) If TxtTotal.Text.ToDecimal <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = TxtTotal.Text.ToDecimal : DR("Orden") = 100 : DR("TipoImpuesto") = "0" : TmpDTImpuestos.Rows.Add(DR)
ObjFacturaDevolucion.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") ObjFacturaDevolucion.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC")
'otros 'otros
ObjFacturaDevolucion.Det_FechaOrdenCompra = TxtDet_FechaOrdenCompra.Text.Trim ObjFacturaDevolucion.Det_FechaOrdenCompra = TxtDet_FechaOrdenCompra.Text.Trim
ObjFacturaDevolucion.Det_OrdenCompra = TxtDet_OrdenCompra.Text.Trim ObjFacturaDevolucion.Det_OrdenCompra = TxtDet_OrdenCompra.Text.Trim
@@ -7273,8 +7305,6 @@ Partial Class Ventas
ObjFacturaDevolucion.CveMoneda = 1 ObjFacturaDevolucion.CveMoneda = 1
End If End If
'DETALLES
ObjFacturaDevolucion.DtDetalle = TmpDT
ObjFacturaDevolucion.DtFirmas = DTmpF ObjFacturaDevolucion.DtFirmas = DTmpF
'CLIENTE 'CLIENTE
@@ -7331,10 +7361,11 @@ Partial Class Ventas
End Sub End Sub
Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi, ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos) As Boolean Private Function RegistrarNCAmortizacion(ObjVentas As ClsVentas, ObjConta As ClsContabilidad, ObjInventario As ClsInventarios, ObjContr As ClsContratos, ObjContPaq As ClsContPAQi,
ByVal factura As Modelos.Factura, ObjBancos As ClsBancos, TmpDTconceptos As DataTable, ByRef ObjEventos As ClsOIEventos, Optional NCDescuento As Boolean = False) As Boolean
Dim ProcesoCorrecto As Boolean = True Dim ProcesoCorrecto As Boolean = True
'Generamos el nuevo folio 'GENERAMOS EL NUEVO FOLIO
Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL()) Dim ObjFolios As New ClsGralFolios(ObjVentas.IniciaTransacSQL())
If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then If ObjFolios.GetFolios(factura.TipoDocto, UsuarioActual.CveEmpresa) Then
@@ -7347,7 +7378,21 @@ Partial Class Ventas
DT.Dispose() DT.Dispose()
End If End If
'** genero los datos de la NC If NCDescuento Then
If DtVentasNC IsNot Nothing AndAlso DtVentasNC.Rows.Count > 0 Then
DtVentasNC.Rows(0)("Importe") = factura.Total
DtVentasNC.Rows(0)("TC") = factura.TipoCambio
DtVentasNC.Rows(0)("TCCambioValuacion") = factura.TipoCambio
End If
ObjFacturaDevolucion.Timbre = PreParaTimbre(ObjFacturaDevolucion)
'Registramos la venta
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, factura.DtDetalle, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True, NCDescuento:=True)
Else
'GENERO LOS DATOS DE LA NC
Dim tmpcon As DataTable = TmpDT.Clone Dim tmpcon As DataTable = TmpDT.Clone
tmpcon.Clear() tmpcon.Clear()
@@ -7407,7 +7452,7 @@ Partial Class Ventas
Next Next
'**** impuestos locales '**** IMPUESTOS LOCALES
factura.DtDetalle = tmpcon factura.DtDetalle = tmpcon
Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte").ToDecimal Dim TotalSubTotal As Decimal = tmpcon.SUM("TotalImporte").ToDecimal
@@ -7441,34 +7486,10 @@ Partial Class Ventas
'Registramos la venta 'Registramos la venta
GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, tmpcon, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True) GuardarVenta(ObjVentas, ObjConta, ObjInventario, ObjContr, factura, tmpcon, -1, ObjContPaq, ObjBancos, EsNCAmortizacion:=True)
''Timbramos
'If factura.TipoDocto.Contiene("Ing", "Egs", "Ant") Then
' If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso UsuarioActual.Empresa.FacturaProduccion Then
' Dim sw As New Diagnostics.Stopwatch
' sw.Start()
' ''factura INGRESO / EGRESO
' Dim ObjTimbrado As New Modelos.Timbrado
' Dim FM As New Modelos.FemsaFactura
' Dim TmpDT7Eleven As New DataTable
' Dim TmpDTComplementosTimbrado As New DataTable
' 'PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado)
' '**
' ObjTimbrado.TimbrarFactura(UsuarioActual, factura, FM, TmpDT, TmpDTImpuestos, TmpDT7Eleven, TmpDTComplementosTimbrado, Ruta, LstFordASN, TxtFordGSDB.Text)
' sw.Stop()
' 'GuardaLogTimbrado(sw.ElapsedMilliseconds.ToString, UsuarioActual.Empresa.CvePAC)
' End If
'End If
Else Else
ErrorList.Add("No se encontró un producto para generar la nota de crédito") ErrorList.Add("No se encontró un producto para generar la nota de crédito")
End If End If
End If
Return ProcesoCorrecto Return ProcesoCorrecto
End Function End Function
@@ -8934,7 +8955,7 @@ Partial Class Ventas
#Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO " #Region " GUARDAR - VENTA, PREPOLIZAS, INV, ESTIMACIONES, AC, NOTA DE CRÉDITO "
Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer, Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer,
ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing,
ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False) ByRef Optional ObjCliente As ClsClientes = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False)
Dim Msgok As New StringBuilder Dim Msgok As New StringBuilder
Dim CveAlmacenTraspasoOrigen As Integer = -1 Dim CveAlmacenTraspasoOrigen As Integer = -1
@@ -9255,10 +9276,10 @@ Partial Class Ventas
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
'prepoliza 'prepoliza
GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion) GuardarVentaPrePolizas(ObjConta, factura, TmpDTDetalle, CveNCaVincular, objContPaqi, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento)
If ErrorList.Count = 0 Then If ErrorList.Count = 0 Then
'inventarios 'inventarios
If Not EsNCAmortizacion Then If Not EsNCAmortizacion AndAlso Not NCDescuento Then
If GuardarVentaInventarios(ObjInventario, ObjConta, factura) Then If GuardarVentaInventarios(ObjInventario, ObjConta, factura) Then
ErrorList.Add("Ocurrio un error al Guardar Inventario") ErrorList.Add("Ocurrio un error al Guardar Inventario")
End If End If
@@ -9284,7 +9305,7 @@ Partial Class Ventas
End Sub End Sub
Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer, Private Sub GuardarVentaPrePolizas(ByRef ObjConta As ClsContabilidad, factura As Modelos.Factura, TmpDTDetalleMovimientos As DataTable, CveNCaVincular As Integer,
ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing,
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False) ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False)
Dim CveIE As Integer = -1 Dim CveIE As Integer = -1
Dim DT As DataTable = Nothing Dim DT As DataTable = Nothing
@@ -9303,7 +9324,7 @@ Partial Class Ventas
If DdlTipoComprobante.SelectedValue <> "Cot" Then If DdlTipoComprobante.SelectedValue <> "Cot" Then
If factura.CvePrePoliza > 0 Then If factura.CvePrePoliza > 0 Then
If ProcesoPrepolizas(ObjConta, factura, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion) Then If ProcesoPrepolizas(ObjConta, factura, CveIE, TmpDTDetalleMovimientos, objContPaqi, 1, ObjBancos, ObjVentas, ObjEventos:=ObjEventos, EsNCAmortizacion:=EsNCAmortizacion, NCDescuento:=NCDescuento) Then
ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico") ErrorList.Add("Ocurrió un error al agregar los Movimientos de la prepoliza.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
End If End If
@@ -9314,7 +9335,7 @@ Partial Class Ventas
End Sub End Sub
Private Function ProcesoPrepolizas(ByRef ObjConta As ClsContabilidad, ObjFactura As Modelos.Factura, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi, Private Function ProcesoPrepolizas(ByRef ObjConta As ClsContabilidad, ObjFactura As Modelos.Factura, CveIE As Integer, TmpDTDetalle As DataTable, ByRef objContPaqi As ClsContPAQi,
Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing, Optional ValorMultiplicador As Integer = 1, ByRef Optional ObjBancos As ClsBancos = Nothing, ByRef Optional ObjVentas As ClsVentas = Nothing,
ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False) As Boolean ByRef Optional ObjEventos As ClsOIEventos = Nothing, Optional EsNCAmortizacion As Boolean = False, Optional NCDescuento As Boolean = False) As Boolean
Try Try
Dim DT As DataTable Dim DT As DataTable
Dim CvePlantilaPoliza As Integer Dim CvePlantilaPoliza As Integer
@@ -9960,8 +9981,16 @@ Partial Class Ventas
Next Next
If UsuarioActual.Empresa.Funcionalidad(344) = "1" Then If UsuarioActual.Empresa.Funcionalidad(344) = "1" Then
If ListaRemisionesNC IsNot Nothing Then Dim ListaNC As List(Of Modelos.Factura) = Nothing
For Each ObjRNC As Modelos.Factura In ListaRemisionesNC
If NCDescuento Then
ListaNC = ListaNCDesc
Else
ListaNC = ListaRemisionesNC
End If
If ListaNC IsNot Nothing Then
For Each ObjRNC As Modelos.Factura In ListaNC
If ObjRNC.TipoDocto = "RNC" Then If ObjRNC.TipoDocto = "RNC" Then
importeMovimiento = ObjRNC.TotalRemNCAplicado * -1 importeMovimiento = ObjRNC.TotalRemNCAplicado * -1
importeMX = importeMovimiento * tipoCambio * Multiplicador importeMX = importeMovimiento * tipoCambio * Multiplicador
@@ -10101,7 +10130,7 @@ Partial Class Ventas
importeMovimiento = 0 importeMovimiento = 0
Case 150 'Descuento sobre ventas Case 150 'Descuento sobre ventas
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion Then If (ObjFactura.TipoDocto.Contiene("Egs", "Dev") AndAlso Not EsNCAmortizacion) OrElse NCDescuento Then
Dim ConceptoContableAplicar = 150 Dim ConceptoContableAplicar = 150
Dim CveVentaAplicar = ObjFactura.CveVenta Dim CveVentaAplicar = ObjFactura.CveVenta
@@ -13815,6 +13844,13 @@ Partial Class Ventas
UpINV.Update() UpINV.Update()
UPPPS.Update() UPPPS.Update()
End Sub End Sub
Private Sub CargaPorcentajeMarcas()
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetPorcentajeMarcas(CveCliente) Then
DtPorcentajeMarcas = ObjPS.DtResultados.Copy()
End If
ObjPS.Dispose()
End Sub
Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
PU As Decimal, Descuento As Decimal, PU As Decimal, Descuento As Decimal,
CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String,
@@ -13891,13 +13927,6 @@ Partial Class Ventas
End If End If
End If End If
If Not ClienteDesglosaIEPS Then
If Not RegeneraIEPS Then
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString.ToDecimal)
End If
DrPS("IEPSPorcentaje") = 0
End If
'verifica si tiene ventaminima 'verifica si tiene ventaminima
If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then
'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
@@ -13907,6 +13936,56 @@ Partial Class Ventas
End If End If
End If End If
If Not ClienteDesglosaIEPS Then
If Not RegeneraIEPS Then
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString.ToDecimal)
End If
DrPS("IEPSPorcentaje") = 0
End If
'VERIFICA SI APLICAN CONDICIONES COMERCIALES
If DtPorcentajeMarcas IsNot Nothing AndAlso DtPorcentajeMarcas.Rows.Count > 0 Then
'VERIFICA SI EL PRODUCTO TIENE ESPECIFICADA UNA MARCA
If Not String.IsNullOrEmpty(DrPS("CveMarca").ToString()) AndAlso DrPS("CveMarca").ToString().ToEntero() > 0 Then
Dim RowPorcentaje = DtPorcentajeMarcas.FiltroPrimero($"CveMarca={DrPS("CveMarca").ToString()}")
'REALIZA LOS DESCUENTOS DE ACUERDO AL PORCENTAJE POR MARCA
If RowPorcentaje IsNot Nothing Then
Dim PorcentajeProducto = RowPorcentaje("PorcentajeProducto").ToString().ToDecimal() / 100D
Dim PorcentajeProducto2 = RowPorcentaje("PorcentajeProducto2").ToString().ToDecimal() / 100D
Dim PorcentajeProducto3 = RowPorcentaje("PorcentajeProducto3").ToString().ToDecimal() / 100D
Dim TotalInicial = (Cantidad * (PU)) - Descuento
Dim TotalFinal = TotalInicial
'SI APLICA EL PRIMER DESCUENTO
If PorcentajeProducto > 0 Then
Dim Descuento1 = TotalInicial * PorcentajeProducto
Dim Total2 = (TotalInicial - Descuento1)
'SI APLICA EL SEGUNDO DESCUENTO
If PorcentajeProducto2 > 0 Then
Dim Descuento2 = Total2 * PorcentajeProducto2
Dim Total3 = (Total2 - Descuento2)
'SI APLICA EL TERCER DESCUENTO
If PorcentajeProducto3 > 0 Then
Dim Descuento3 = Total3 * PorcentajeProducto3
TotalFinal = Total3 - Descuento3
Else
TotalFinal = Total3
End If
Else
TotalFinal = Total2
End If
Else
TotalFinal = TotalInicial
End If
Descuento += ((Cantidad * PU) - TotalFinal)
End If
End If
End If
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
Row("PU") = PU Row("PU") = PU
@@ -13939,8 +14018,6 @@ Partial Class Ventas
Row("IVA") = Row("PorcentajeIVA") Row("IVA") = Row("PorcentajeIVA")
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales) Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales)
Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales) Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales)
Row("PorcentajeRetIVA") = ClienteRetIVA Row("PorcentajeRetIVA") = ClienteRetIVA
@@ -14575,7 +14652,7 @@ Partial Class Ventas
ConfiguraTipoDocto() ConfiguraTipoDocto()
End If End If
End Sub End Sub
Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True) Private Sub CalculaTotalesVenta(Optional RecalculaImpuestosLocales As Boolean = True, Optional NCDescuento As Boolean = False)
Dim TotalSubTotal As Decimal = TmpDT.SUM("TotalImporte").ToDecimal Dim TotalSubTotal As Decimal = TmpDT.SUM("TotalImporte").ToDecimal
Dim TotalDescuentos As Decimal = TmpDT.SUM("Descuento").ToDecimal Dim TotalDescuentos As Decimal = TmpDT.SUM("Descuento").ToDecimal
@@ -16721,15 +16798,30 @@ Partial Class Ventas
Private Function ValidaPagosContado() As Boolean Private Function ValidaPagosContado() As Boolean
Dim Retorno = False Dim Retorno = False
If (UsuarioActual.CveEmpresa = 140) AndAlso (Not PermiteCredito) AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) And TxtTotal.Text.ToDecimal > 0 Then If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.CveEmpresa = 140) AndAlso (Not PermiteCredito) AndAlso (DtPagos Is Nothing OrElse DtPagos.Rows.Count = 0) And TxtTotal.Text.ToDecimal > 0 Then
Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia) Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia)
Retorno = True Retorno = True
End If End If
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
Dim TotalNC As Decimal = If(ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0, ListaNCDesc.Sum(Function(f) f.TotalRemNCAplicado), 0)
If TotalNC > 0 Then
If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TotalNC Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
Retorno = True
End If
Else
If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia) Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
Retorno = True Retorno = True
End If End If
End If
Else
If (DtPagos.SUM("Importe").ToString.ToDecimal + Total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor verifique.", TipoMensaje.MsgAdvertencia)
Retorno = True
End If
End If
Return Retorno Return Retorno
End Function End Function
@@ -20504,6 +20596,16 @@ Partial Class Ventas
ObjMovtos.Dispose() ObjMovtos.Dispose()
GvRemisionesNC.DataBind() GvRemisionesNC.DataBind()
End Sub End Sub
Private Sub CargaDescRNC()
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, -1, TipoDocto:="RNC") Then
GvDescNC.DataSource = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act' AND CveVenta > 0", "Moneda, OrdenVencimiento, FechaVencimiento")
End If
ObjMovtos.Dispose()
GvDescNC.DataBind()
UpDescNC.Update()
End Sub
Protected Sub GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Protected Sub GvCxC_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
@@ -20540,8 +20642,13 @@ Partial Class Ventas
End If End If
End If End If
AplicarNC(DdlNCPS.SelectedValue.ToEntero)
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=DdlNCPS.SelectedValue.ToEntero).FiltroPrimero("") RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC")
End Sub
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False)
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DrPS Is Nothing Then If DrPS Is Nothing Then
Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError) Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError)
Exit Sub Exit Sub
@@ -20556,11 +20663,6 @@ Partial Class Ventas
Exit Sub Exit Sub
End If End If
End If End If
If DdlTipoComprobante.SelectedValue = "Ant" Then CveAnticipo = CveVenta
DdlTipoComprobante.SelectedValueExist("Egs")
'CREAMOS DT PARA UTILIZAR AL TIMBRAR 'CREAMOS DT PARA UTILIZAR AL TIMBRAR
InicializaDTVentasNC() InicializaDTVentasNC()
@@ -20579,6 +20681,13 @@ Partial Class Ventas
DtImpuestos.AcceptChanges() DtImpuestos.AcceptChanges()
If AplicaNCMasiva Then If AplicaNCMasiva Then
If NCDescuento Then
For Each Gvr As GridViewRow In GvDescNC.Rows
If Gvr.FCCheckBox("ChkAplicar").Checked Then
DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal), True, MissingSchemaAction.Ignore)
End If
Next
Else
For Each Gvr As GridViewRow In GvCxC.Rows For Each Gvr As GridViewRow In GvCxC.Rows
If Gvr.FCCheckBox("ChkCxC").Checked Then If Gvr.FCCheckBox("ChkCxC").Checked Then
DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal), True, MissingSchemaAction.Ignore) DtImpuestos.Merge(CargaDtImpuestosNC(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal), True, MissingSchemaAction.Ignore)
@@ -20586,6 +20695,7 @@ Partial Class Ventas
CargaNCDT(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal) CargaNCDT(Gvr.DataKey("CveVenta").ToString.ToEntero, Gvr.FCTextBox("TxtImporte").Text.ToString.ToDecimal)
End If End If
Next Next
End If
Else Else
DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal) DtImpuestos = CargaDtImpuestosNC(CveVenta, TxtNCImporte.Text.Trim.ToDecimal)
End If End If
@@ -20613,16 +20723,25 @@ Partial Class Ventas
Exit Sub Exit Sub
End If End If
DtImpuestos = query.QueryToDataTable(False) DtImpuestos = query.QueryToDataTable(False)
If Not NCDescuento Then
LimpiaDocumentoNC() LimpiaDocumentoNC()
End If
Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero
Dim SubProyecto = DrSubProyecto("SubProyecto").ToString Dim SubProyecto = DrSubProyecto("SubProyecto").ToString
Dim CveProyecto = DrSubProyecto("CveProyecto").ToString.ToEntero Dim CveProyecto = DrSubProyecto("CveProyecto").ToString.ToEntero
Dim Proyecto = DrSubProyecto("Proyecto").ToString Dim Proyecto = DrSubProyecto("Proyecto").ToString
AplicaNC = True
If Not NCDescuento Then
If DdlTipoComprobante.SelectedValue = "Ant" Then CveAnticipo = CveVenta
DdlTipoComprobante.SelectedValueExist("Egs")
For Each Dr As DataRow In DtImpuestos.Rows For Each Dr As DataRow In DtImpuestos.Rows
AgregaTempDT(DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero, AgregaTempDT(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, DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, Proyecto, CveSubProyecto, SubProyecto,
@@ -20631,22 +20750,19 @@ Partial Class Ventas
DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1) DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
Next Next
TrTipoRelacion.Visible = True
DdlTiposRelacion.SelectedValueExist("1")
GvPS.DataSource = TmpDT GvPS.DataSource = TmpDT
GvPS.DataBind() GvPS.DataBind()
CalculaTotalesVenta(True) CalculaTotalesVenta(True)
TrTipoRelacion.Visible = True
DdlTiposRelacion.SelectedValueExist("1")
'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 '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
If Not AplicaNCMasiva Then If Not AplicaNCMasiva Then
Dim TT As Decimal = TxtNCImporte.Text.ToDecimal Dim TT As Decimal = TxtNCImporte.Text.ToDecimal
If TT > TxtTotal.Text.ToDecimal Then TT = TxtTotal.Text.ToDecimal If TT > TxtTotal.Text.ToDecimal Then TT = TxtTotal.Text.ToDecimal
CargaNCDT(CveVenta, TT) CargaNCDT(CveVenta, TT)
End If End If
'verifica el tipo de cambio que se actualice 'verifica el tipo de cambio que se actualice
If DdlMoneda.SelectedValue <> "1" Then If DdlMoneda.SelectedValue <> "1" Then
@@ -20656,11 +20772,10 @@ Partial Class Ventas
UpPS.Update() UpPS.Update()
LBNotaCredito.Visible = False LBNotaCredito.Visible = False
RegistraScript("$('#ModalAplicarNC').modal('hide');", "EscondeModalNC")
AplicaNC = True
CambiaTipoDocto() CambiaTipoDocto()
End If
End Sub End Sub
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable
@@ -20684,8 +20799,6 @@ Partial Class Ventas
Else Else
Total = TxtTotal.Text.ToDecimal Total = TxtTotal.Text.ToDecimal
SubTotal = TxtSubTotal.Text.ToDecimal SubTotal = TxtSubTotal.Text.ToDecimal
End If End If
ObjVentas.Dispose() ObjVentas.Dispose()
@@ -22061,7 +22174,10 @@ Partial Class Ventas
Protected Sub BtnGuardarRemisiones_Click(sender As Object, e As EventArgs) Handles BtnGuardarRemisiones.Click Protected Sub BtnGuardarRemisiones_Click(sender As Object, e As EventArgs) Handles BtnGuardarRemisiones.Click
If GvRem.Rows.Count > 0 Or GvRemPS.Rows.Count > 0 Then If GvRem.Rows.Count > 0 Or GvRemPS.Rows.Count > 0 Then
'Checa las facturas selecionadas 'Checa las facturas selecionadas
VerificaRemisiones(DTRemisiones) If Not VerificaRemisiones(DTRemisiones) Then
Alert("La cantidad/total debe ser mayor que 0", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim dtSeleccionadas As DataTable = DTRemisiones.FiltraParametros("Aplicado = True") Dim dtSeleccionadas As DataTable = DTRemisiones.FiltraParametros("Aplicado = True")
Dim CveContrato = DTRemisiones.FiltroPrimeroValor("CveContrato", "Aplicado = True").ToEntero Dim CveContrato = DTRemisiones.FiltroPrimeroValor("CveContrato", "Aplicado = True").ToEntero
@@ -22231,8 +22347,17 @@ Partial Class Ventas
RegistraScript("$('#DivRemisiones').modal('hide');", "DivRemisionesHide") RegistraScript("$('#DivRemisiones').modal('hide');", "DivRemisionesHide")
End Sub End Sub
Private Sub VerificaRemisiones(ByRef dt As DataTable) Private Function VerificaRemisiones(ByRef dt As DataTable) As Boolean
Dim Valido As Boolean = True
If ChkRemProductos.Checked Then If ChkRemProductos.Checked Then
Valido = Not (From GvRow In GvRemPS.Rows.Cast(Of GridViewRow)
Let Cantidad = GvRow.FCTextBox("TxtCantidadRem").Text.Trim().ToEntero(), Aplicar = GvRow.FCCheckBox("Chk").Checked
Where GvRow.RowType = DataControlRowType.DataRow AndAlso Cantidad <= 0 AndAlso Aplicar
Select GvRow
).Any
If Valido Then
For Each Gvr As GridViewRow In GvRemPS.Rows For Each Gvr As GridViewRow In GvRemPS.Rows
If Gvr.RowType = DataControlRowType.DataRow Then If Gvr.RowType = DataControlRowType.DataRow Then
Dim ChkAplicar As CheckBox = Gvr.FCCheckBox("Chk") Dim ChkAplicar As CheckBox = Gvr.FCCheckBox("Chk")
@@ -22244,6 +22369,8 @@ Partial Class Ventas
dt.AcceptChanges() dt.AcceptChanges()
End If End If
Next Next
End If
Else Else
For Each Gvr As GridViewRow In GvRem.Rows For Each Gvr As GridViewRow In GvRem.Rows
If Gvr.RowType = DataControlRowType.DataRow Then If Gvr.RowType = DataControlRowType.DataRow Then
@@ -22257,7 +22384,9 @@ Partial Class Ventas
End If End If
Next Next
End If End If
End Sub
Return Valido
End Function
Private Sub CargaConceptosRemisionPorFacturar(CveRemisiones As String, TipoCargas As Integer) Private Sub CargaConceptosRemisionPorFacturar(CveRemisiones As String, TipoCargas As Integer)
Dim ObjClientes As New ClsClientes Dim ObjClientes As New ClsClientes
If ObjClientes.GetVentasRemisionesTotales(CveCliente, CveRemisiones, TipoCargas) Then If ObjClientes.GetVentasRemisionesTotales(CveCliente, CveRemisiones, TipoCargas) Then
@@ -22877,7 +23006,7 @@ Partial Class Ventas
CambiaTipoDocto() CambiaTipoDocto()
CambiaSucursalGeneral() CambiaSucursalGeneral()
CargaAnticipos(CveCliente) CargaAnticipos(CveCliente)
CargaRestriccionesCreditoCliente() CargaRestriccionesCreditoCliente(CveVenta:=-1)
UpParametros.Update() UpParametros.Update()
End Sub End Sub
@@ -23274,4 +23403,158 @@ Partial Class Ventas
RegistraScript("CerrarModalRemNC();") RegistraScript("CerrarModalRemNC();")
End Sub End Sub
Protected Sub LnkDescuentosRNC_Click(sender As Object, e As EventArgs)
CargaDescRNC()
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)
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
Dim TotalRemNCAplicado As Decimal = 0
For Each GvRow As GridViewRow In GvDescNC.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
LblDescuentosRNC.Text = TotalRemNCAplicado.FormatoNumero
LblTotalNC.Text = (TxtTotal.Text.ToDecimal() - TotalRemNCAplicado).FormatoNumero
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
AplicarNC(CvePS, True)
UpPS.Update()
RegistraScript("$('#ModalAplicarDescuentoNC').modal('hide'); ")
End Sub
Protected Function CreaDTDetalleNCDescuento() As DataTable
Dim Dt As DataTable = TmpDT.Clone()
Dt.Rows.Clear()
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)
Return Dt
End If
Dim CvePS = DrPS("CvePS").ToString().ToEntero()
Dim TotalCalculableImpuestos As Decimal = 0
Dim PU = Math.Round(ListaNCDesc.Sum(Function(RNC) RNC.TotalRemNCAplicado), 6) ' el precio unitario puede llevar hasta 6 decimales permitidos
Dim Cantidad As Decimal = 1
Dim Descuento As Decimal = 0
Dim Row As DataRow = Dt.NewRow()
Row("CveProyecto") = DdlProyecto.SelectedValue.ToEntero()
Row("Proyecto") = DdlProyecto.SelectedItem.Text
Row("CveSubProyecto") = DdlSubProyecto.SelectedValue.ToEntero()
Row("SubProyecto") = DdlSubProyecto.SelectedItem.Text
Row("SerieLote") = "-1"
Row("TiempoEntrega") = ""
Row("Orden") = Dt.Rows.Count + 1
Row("Cantidad") = Cantidad
Row("CveUM") = DrPS("CveUM").ToString().ToEntero()
Row("UM") = ""
Row("CveClasificacion") = DrPS("CveClasificacion").ToString().ToEntero()
Row("Clasificacion") = ""
Row("CvePS") = CvePS
Row("Obs") = ""
TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
Row("PU") = PU
Row("Codigo") = DrPS("Codigo")
Row("NoIdentificacion") = DrPS("Codigo")
Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
If Modalidad = "U" Then
Row("Consec") = Index
Else
Row("Consec") = TmpDT.Rows.Count + 1
End If
Row("PS") = DrPS("PS")
Row("CodigoPS") = DrPS("PSCodigo").ToString
Row("CveTipoPS") = DrPS("CveTipoPS")
Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
Row("CveTamaño") = DrPS("CveTamaño")
Row("CveClasificacion") = DrPS("CveClasificacion")
Row("Clasificacion") = DrPS("Clasificacion")
If DrPS("IVA").ToString.Contiene("-1", "") Then
Row("PorcentajeIVA") = PorcentajeIVA
Else
Row("PorcentajeIVA") = DrPS("IVA")
End If
Row("IVA") = Row("PorcentajeIVA")
Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
Row("ImporteRetIVA") = Math.Round(ClienteRetIVA * TotalCalculableImpuestos, NumeroDecimales)
Row("ImporteRetISR") = Math.Round(ClienteRetISR * TotalCalculableImpuestos, NumeroDecimales)
Row("PorcentajeRetIVA") = ClienteRetIVA
Row("PorcentajeRetISR") = ClienteRetISR
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales)
Row("IEPS") = Row("ImporteIEPS")
Row("Descuento") = Math.Round(Descuento, NumeroDecimales)
Row("TipoDescuento") = HdnTipoDescuento.Value
Row("Total") = (Cantidad * PU)
Row("TotalImporte") = Math.Round(Cantidad * PU, NumeroDecimales)
Row("SATClaveProdServ") = DrPS("SATClavePS")
Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
If UsuarioActual.Empresa.UsaAC Then
Row("CvePresupuestoIngreso") = Me.DdlFuenteRecaudacion.SelectedValue
End If
Row("EntregaDirecta") = -1
'Contratos
Row("CveContratoDetalle") = -1
Row("CveVentaDetalle") = -1
Row("CveMovimientoDetallePedido") = -1
Row("CveOrdenCompraDetalle") = -1
Row("CveVentaDetalleRemision") = -1
Row("CveVentaDetalleCotizacion") = -1
Row("CveVentaDetallePedido2") = -1
Row("CuentaPredial") = "-1"
Row("Consec") = 1
'RECARGAR GV
Dt.Rows.Add(Row)
Return Dt
End Function
End Class End Class