Desglose de productos al seleccionar RNC de bonificacion

This commit is contained in:
2021-07-21 23:55:40 -07:00
parent 19ee45b2d5
commit 4b1ec81649
4 changed files with 464 additions and 132 deletions

View File

@@ -5083,7 +5083,7 @@ Public Class ClsPaginas
PaginaDict.Add("/Ventas/RepAuxiliarFacturas.aspx".ToUpper(), 567)
PaginaDict.Add("/Ventas/CatAutorizacionLimites.aspx".ToUpper(), 781)
PaginaDict.Add("/Ventas/RepComisionesServec.aspx".ToUpper(), 782)
PaginaDict.Add("/Ventas/RepComisionesServecDetalle.aspx".ToUpper(), 783)
PaginaDict.Add("/Ventas/RepComisionesServecDetalle.aspx".ToUpper(), 782)
#End Region

View File

@@ -5170,7 +5170,7 @@ Public Class ClsVentas
#End Region
Public Function AddAutorizacionLimite(CveEmpresa As Integer, CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveEstatus As Integer, CveUsuario As Integer, TipoAutorizacion As Integer, TipoDocumento As String) As Boolean
Public Function AddAutorizacionLimite(CveEmpresa As Integer, CveCliente As Integer, CveVendedor As Integer, Importe As Decimal, CveEstatus As Integer, CveUsuario As Integer, TipoAutorizacion As Integer, TipoDocumento As String, Optional DiasVencidos As Integer = 0) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_AutorizacionLimitesAdd")
With SqlAdapter.SelectCommand.Parameters
@@ -5182,6 +5182,7 @@ Public Class ClsVentas
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
.Add("@TipoAutorizacion", SqlDbType.Int).Value = TipoAutorizacion
.Add("@TipoDocumento", SqlDbType.VarChar).Value = TipoDocumento
.Add("@DiasVencidos", SqlDbType.Int).Value = DiasVencidos
End With
Try
SqlAdapter.Fill(Data)

View File

@@ -6317,7 +6317,8 @@
<div class="row">
<div class="col-md-2">Folio Fiscal</div>
<div class="col-md-10">
<asp:TextBox ID="TxtModalFolioFiscal" runat="server" Width="100%"></asp:TextBox></div>
<asp:TextBox ID="TxtModalFolioFiscal" runat="server" Width="100%"></asp:TextBox>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
@@ -7322,12 +7323,13 @@
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body form-horizontal form-row-sepe formnombottom">
<div class="row" style="margin-right: 10px;" align="right">
<input type="text" id="TxtBusquedaNCBonificaciones" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaNCBonificaciones','{0}')", GvDescNCBonificaciones.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaNCBonificaciones','{0}')", GvDescNCBonificaciones.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
<div class="row">
<div class="col-md-12">
<asp:CheckBox ID="ChkMostarProductosRNCDesBonificacion" runat="server" AutoPostBack="true" Text="Mostrar Productos" OnCheckedChanged="ChkMostarProductosRNCDesBonificacion_CheckedChanged" />
</div>
</div>
<div class="portlet-body form-horizontal form-row-sepe formnombottom">
<div id="DivRNCBonDescTotal" runat="server" visible="false" class="row">
<div class="col-md-12" style="max-height: 440px; overflow: auto">
<asp:GridView ID="GvDescNCBonificaciones" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveVenta,CveVentaRNCCargo" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn" GridLines="None">
@@ -7359,19 +7361,37 @@
</asp:GridView>
</div>
</div>
<%-- <div class="row">
<div class="col-md-12">
<table border="0" rules="none" class="well TextTab" style="float: right;" runat="server">
<tr align="right">
<td style="border: 1px none white"><b>Saldo Maximo Utilizable.:</b></td>
<td>
<asp:Label ID="LblSaldoMaximoBonificacion" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00"></asp:Label></td>
<td align="right">&nbsp;
</td>
</tr>
</table>
<div class="row" id="DivRNCBonDescDetalle" runat="server" visible="false">
<div class="col-md-12" style="max-height: 440px; overflow: auto">
<asp:GridView ID="GvDescNCBonDetalle" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveVenta,CveVentaDetalleRNC,CvePS,PU,PorcentajeIVA" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ChkAplicar" runat="server" />
<asp:HiddenField ID="HdnPorcentajeIVA" ClientIDMode="Static" runat="server" Value='<%# Eval("PorcentajeIVA").ToString %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cantidad">
<ItemTemplate>
<asp:TextBox ID="TxtCantidadRNC" runat="server" Text='<%#Eval("CantidadPendiente").ToString%>' MaxLength="12" Width="46px" Height="24px"></asp:TextBox>
<asp:RangeValidator ID="RVCantRNC" runat="server" Type="Double" MinimumValue="0" MaximumValue='<%#Eval("CantidadPendiente").ToString%>' ErrorMessage="Cantidad Excedida" ControlToValidate="TxtCantidadRNC" Display="None" ValidationGroup="VGAplicarRNC"></asp:RangeValidator>
<ajax:ValidatorCalloutExtender ID="VCECantidad3" runat="server" HighlightCssClass="vco" TargetControlID="RVCantRNC" Width="300px"></ajax:ValidatorCalloutExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Producto" DataField="CodigoPS" ItemStyle-HorizontalAlign="Left" />
<asp:HyperLinkField DataNavigateUrlFields="CveVenta" Target="_blank" DataNavigateUrlFormatString="/Ventas/Ventas.aspx?CveVenta={0}" DataTextField="Folio" 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:HiddenField ID="HdnPU" ClientIDMode="Static" runat="server" Value='<%# Eval("PU").ToString %>' />
<asp:Literal ID="TtlTotal" runat="server" Text='<%# Eval("Total", "{0:N2}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>--%>
</div>
</div>
</div>
@@ -7748,6 +7768,74 @@
}
}
function CalculaSaldoRNCChkDetalleBonificacion(TxtCantidad, CantidadPendiente, ImporteTotal, Chk) {
//ImportesRNCCargo
let Importe = 0;
if (Chk.checked) {
let SaldoMaximoUtilizable = 999999999;
let ImportesAsignados = 0;
$('.ImportesRNCDetalleBonificacion').each(function () {
if (Chk.id != $(this).find("td").eq(0).find(":checkbox").attr('id')) {
let seleccionado = $(this).find("td").eq(0).find(":checkbox").is(':checked');
if (seleccionado) {
let cantidad = ToDouble($(this).find("td").eq(1).find(":text").val());
let porcentajeIVA = ToDouble($(this).find("td").eq(0).find(":hidden").val());
let precio = ToDouble($(this).find("td").eq(5).find(":hidden").val());
let totalcalculableImpuestos = (cantidad * precio);
let iva = ToDouble((totalcalculableImpuestos * porcentajeIVA).toFixed(2));
ImportesAsignados += totalcalculableImpuestos + iva;
}
}
});
Importe = SaldoMaximoUtilizable - ImportesAsignados;
if (Importe > 0) {
} else {
if (SaldoMaximoUtilizable > 0) {
Importe = 0;
Chk.checked = false;
} else {
Importe = 0;
}
}
} else {
Importe = 0;
}
Importe = ToDouble(Importe.toFixed(2));
if (Importe > 0) {
let pu = (ImporteTotal / CantidadPendiente);
if (pu > 0) {
const cantidadSugerida = (Importe / pu);
if (cantidadSugerida > CantidadPendiente) {
TxtCantidad.value = CantidadPendiente.toString();
}else {
TxtCantidad.value = cantidadSugerida.toString();
}
}else {
TxtCantidad.value = "0";
}
}else {
TxtCantidad.value = "0";
}
}
function LimitaSaldoRNCChk(TxtImporte, Saldo) {

View File

@@ -160,6 +160,25 @@ Partial Class Ventas
ViewState("TmpDTRNCDetalleSelecciondas") = value
End Set
End Property
Private Property TmpDTRNCBonificacionDetalle As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCBonificacionDetalle")), Nothing, CType(ViewState("TmpDTRNCBonificacionDetalle"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCBonificacionDetalle") = value
End Set
End Property
Private Property TmpDTRNCBonificacionDetalleSeleccionadas As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCBonificacionDetalleSeleccionadas")), Nothing, CType(ViewState("TmpDTRNCBonificacionDetalleSeleccionadas"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCBonificacionDetalleSeleccionadas") = value
End Set
End Property
Private Property TmpDTError As DataTable
Get
Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable))
@@ -1932,6 +1951,14 @@ Partial Class Ventas
ViewState("AplicaRNCXDetalle") = value
End Set
End Property
Private Property AplicaRNCBonificacionXDetalle As Boolean
Get
Return CBool(IfNull(ViewState("AplicaRNCBonificacionXDetalle"), "False", ViewState("AplicaRNCBonificacionXDetalle")))
End Get
Set(value As Boolean)
ViewState("AplicaRNCBonificacionXDetalle") = value
End Set
End Property
Private Property AplicaRelacionManual As Boolean
Get
Return CBool(IfNull(ViewState("AplicaRelacionManual"), "False", ViewState("AplicaRelacionManual")))
@@ -25054,7 +25081,16 @@ Partial Class Ventas
Case "2" 'BONIFICACIONES
DivRNCCargoDesc.Visible = False
DivRNCBonDesc.Visible = True
If ChkMostarProductosRNCDesBonificacion.Checked Then
DivRNCBonDescTotal.Visible = False
DivRNCBonDescDetalle.Visible = True
CargaRNCDetalleDescBonificacion()
Else
DivRNCBonDescTotal.Visible = True
DivRNCBonDescDetalle.Visible = False
CargaRNCDesc(True, False)
End If
Case "3" 'AJUSTE/GARANTIAS
LtlCargoDesc.Text = "AJUSTES/GARANTIAS"
DivRNCCargoDesc.Visible = True
@@ -25091,6 +25127,13 @@ Partial Class Ventas
UpModalRemisionesNC.Update()
End Sub
Protected Sub ChkMostarProductosRNCDesBonificacion_CheckedChanged(sender As Object, e As EventArgs)
RblRNCTipoDesc_SelectedIndexChanged(RblRNCTipo, EventArgs.Empty)
UpModalRemisionesNC.Update()
End Sub
Private Sub CargaRNC(Optional CveVentaUsado As Integer = -1, Optional CargarBonificaciones As Boolean = False, Optional CargarSoloGarantias As Boolean = False)
Dim DtNC As DataTable = Nothing
@@ -25291,6 +25334,37 @@ Partial Class Ventas
UpDescNC.Update()
End Sub
Private Sub CargaRNCDetalleDescBonificacion()
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
Me.TmpDTRNCBonificacionDetalle = ObjMovtos.DtResultados.Copy()
End If
ObjMovtos.Dispose()
Me.TmpDTRNCBonificacionDetalle.Columns.Add(New DataColumn("CveVentaDetalleNCGenerada", GetType(Integer)))
Me.TmpDTRNCBonificacionDetalleSeleccionadas = Nothing
Me.TmpDTRNCBonificacionDetalleSeleccionadas = TmpDTRNCBonificacionDetalle.Clone()
Me.TmpDTRNCBonificacionDetalleSeleccionadas.Clear()
GvDescNCBonDetalle.DataSource = TmpDTRNCBonificacionDetalle.FiltraParametros("TipoRNC = 2")
GvDescNCBonDetalle.DataBind()
'Dim SaldoMaximoUsados As Decimal = Me.TmpDT.SUM("Total", "EsCargo = True").ToDecimal() + Me.TmpDT.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
'If SaldoMaximoUsados > 0 Then
' HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString()
' LblSaldoMaximoUsados.Text = String.Format("{0:N2}", SaldoMaximoUsados)
'Else
' HdnSaldoMaximoUsados.Value = "0"
' LblSaldoMaximoUsados.Text = "0"
'End If
UpDescNC.Update()
End Sub
Private Sub CargaBonificaciones(CveVentaRNCCargo As Integer, AplicarRNC As Boolean)
If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then
TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone()
@@ -25409,6 +25483,15 @@ Partial Class Ventas
Private Sub CargaBonificacionesDesc(CvesVentaRNCCargo As String, AplicarRNC As Boolean)
If ChkMostarProductosRNCDesBonificacion.Checked Then
DivRNCBonDescTotal.Visible = False
DivRNCBonDescDetalle.Visible = True
CargaRNCDetalleDescBonificacion()
Else
DivRNCBonDescTotal.Visible = True
DivRNCBonDescDetalle.Visible = False
If TmpDTRNCBonificacionesSeleccionadas Is Nothing Then
TmpDTRNCBonificacionesSeleccionadas = Me.TmpDTRNCBonificacionesCliente.Clone()
Else
@@ -25491,27 +25574,7 @@ Partial Class Ventas
GvDescNCBonificaciones.DataSource = TmpDTRNCBonificacionesSeleccionadas
GvDescNCBonificaciones.DataBind()
'SI ES CREDITO
'If RBLPago.SelectedValue = "1" Then
' Dim ImporteUsados As Decimal = Me.TmpDTRNCBonificacionesSeleccionadas.SUM("ImporteBonificacion").ToDecimal() + Me.TmpDTRNCBonificacionesSeleccionadas.SUM("IVABonificacion").ToDecimal()
' HdnSMUBonDesc.Value = ImporteUsados.ToString()
' LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", ImporteUsados)
' 'SI ES CONTADO
'ElseIf RBLPago.SelectedValue = "2" Then
' Dim ImporteUsados As Decimal = 0
' For Each Row As DataRow In Me.TmpDT.FiltraParametros("EsCargo = True").Rows
' Dim PUBonificacion As Decimal = GlobalDTAcumTamaños().FiltroPrimeroValor("Bonificacion", $"CvePSCargo={Row("CvePS")}").ToDecimal()
' Dim TotalBonificacion As Decimal = (Row("Cantidad").ToString().ToDecimal() * PUBonificacion)
' Dim IVABonificacion As Decimal = (TotalBonificacion * Row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
' ImporteUsados += TotalBonificacion + IVABonificacion
' Next
' HdnSMUBonDesc.Value = ImporteUsados.ToString()
' LblSaldoMaximoBonificacion.Text = String.Format("{0:N2}", ImporteUsados)
'End If
End If
UpDescNC.Update()
End Sub
@@ -25538,6 +25601,22 @@ Partial Class Ventas
End If
End If
End Sub
Protected Sub GvDescNCBonDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCBonDetalle.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveVentaDetalleRNC").ToEntero() = 0 Then
e.Row.CssClass = "Totales"
e.Row.FCCheckBox("ChkAplicar").Visible = False
e.Row.FCTextBox("TxtCantidadRNC").Visible = False
Else
e.Row.CssClass = "ImportesRNCDetalle"
e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCChkDetalleBonificacion({e.Row.FCTextBox("TxtCantidadRNC").ClientID},{e.Row.DBCampo("CantidadPendiente").ToDouble},{e.Row.DBCampo("Total").ToDouble}, this);")
'e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
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);")
@@ -25866,13 +25945,21 @@ Partial Class Ventas
NCBonificacion = ArrayNC(4).ToEntero()
End If
Dim DrBonRef As DataRow = Nothing
'EN LA NC DE BONIFICACION EL CONCEPTO DEBE SER SIEMPRE 'BONIFICACION POR USADO'
Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCBonificacion).FiltroPrimero("")
If DrPSBonificacion IsNot Nothing Then
CrearDTNCBonificacionDesc(DtImpuestosBonificacion, TmpDTDescNC, DrPSBonificacion, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
DrBonRef = DrPSBonificacion
Else
DrBonRef = DrPS
Alert("No se encontró el concepto de BONIFICACION POR USADO", TipoMensaje.MsgAdvertencia)
CrearDTNCBonificacionDesc(DtImpuestosBonificacion, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
End If
If AplicaRNCBonificacionXDetalle Then
CrearDTNCBonificacionDescDetalle(ListaNCBonificacion, TmpDTDescNC, DrBonRef, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
Else
CrearDTNCBonificacionDesc(DtImpuestosBonificacion, TmpDTDescNC, DrBonRef, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
End If
Else
@@ -26331,6 +26418,93 @@ Partial Class Ventas
Next
End If
End Sub
Private Sub CrearDTNCBonificacionDescDetalle(ListaNC As List(Of Modelos.Factura), ByRef TmpDTCargo As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String)
TmpDTDescNCBonificacion = TmpDTCargo.Clone()
TmpDTDescNCBonificacion.Clear()
For Each RNC In ListaNC
Dim UltimoRenglonRNC As Integer = 1
Dim TotalAcumuladoRNC As Decimal = 0
Dim Terminar As Boolean = False
For Each RowUsado As DataRow In Me.TmpDTRNCBonificacionDetalleSeleccionadas.FiltraParametros($"CveVenta={RNC.CveVenta}", Orderby:="PU").Rows
Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
Dim CvePSCargo As Integer = RowUsado("CvePS").ToString().ToEntero()
Dim Obs = ""
'SI ES ACUMULADOR LAS OBSERVACIOENS DEBEN SER EL NOMBRE DEL ACUMULADOR
If GlobalDTAcumTamaños().FiltroPrimero($"CvePSCargo = {CvePSCargo}") IsNot Nothing Then
Obs = RowUsado("CodigoPS").ToString()
'Else
' Obs = RowUsado("Obs").ToString()
End If
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim())
End If
Dim ImportePU = RowUsado("PU").ToString().ToDecimal
Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU)
Dim ImporteIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2)
Dim ImporteIEPS = 0 '(TotalCalculableImpuestos * RowUsado("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2)
Dim ImporteRetIVA = 0 ' (TotalCalculableImpuestos * RowUsado("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2)
Dim ImporteRetISR = 0 ' (TotalCalculableImpuestos * RowUsado("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2)
Dim ImporteTotal = TotalCalculableImpuestos
TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA)
'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 * RowUsado("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2)
ImporteTotal = TotalCalculableImpuestos
TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR)
End If
'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE
If UltimoRenglonRNC = Me.TmpDTRNCBonificacionDetalleSeleccionadas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows.Count OrElse Terminar Then
Dim Ajuste As Decimal = 0
If Math.Abs(RNC.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then
Ajuste = RNC.TotalRemNCAplicado - TotalAcumuladoRNC
ImporteIVA += Ajuste
End If
End If
UltimoRenglonRNC += 1
AgregaTempDT(TmpDTDescNCBonificacion, 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, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, 0, ImporteRetIVA,
0, ImporteRetISR, 0, ImporteIEPS, -1, 0, ImporteTotal, "", "", -1, -1,
DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalleRNC").ToString().ToEntero())
If Terminar Then
Exit For
End If
Next
Next
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
@@ -29829,6 +30003,7 @@ Partial Class Ventas
#Region "D E S C U E N T O S X R E M I S I O N D E N O T A D E C R E D I T O"
Protected Sub BtnAplicarRemisionNC_Click(sender As Object, e As EventArgs)
Me.AplicaRNCXDetalle = False
Me.AplicaRNCBonificacionXDetalle = False
If ListaRemisionesNC Is Nothing Then
ListaRemisionesNC = New List(Of Modelos.Factura)
@@ -30027,6 +30202,7 @@ Partial Class Ventas
Protected Sub BtnAplicarDesc_Click(sender As Object, e As EventArgs)
Try
Me.AplicaRNCXDetalle = False
Me.AplicaRNCBonificacionXDetalle = False
Dim DrPS As DataRow = Nothing
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
@@ -30215,6 +30391,79 @@ Partial Class Ventas
Exit Sub
End If
'BONIFICACIONES
If ChkMostarProductosRNCDesBonificacion.Checked Then
TmpDTRNCBonificacionDetalleSeleccionadas.Clear()
Me.AplicaRNCBonificacionXDetalle = True
For Each GvRow As GridViewRow In GvDescNCBonDetalle.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim Rows = TmpDTRNCBonificacionDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}")
For Each row In Rows
row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
Dim TotalCalculableImpuestos As Decimal = row("Cantidad").ToString().ToDecimal() * row("PU").ToString().ToDecimal()
Dim IVA As Decimal = (TotalCalculableImpuestos * row("PorcentajeIVA").ToString().ToDecimal()).RoundSQL()
row("IVA") = IVA
row("Total") = (TotalCalculableImpuestos + IVA).RoundSQL
TmpDTRNCBonificacionDetalleSeleccionadas.Rows.Add(row.ItemArray)
Next
End If
End If
Next
Dim TerminarCiclo As Boolean = False
For Each Dr As DataRow In TmpDTRNCBonificacionDetalleSeleccionadas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows
Dim RemNC As New Modelos.Factura(UsuarioActual, Dr("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa)
Dim TotalRNC As Decimal = 0
For Each GvRow As GridViewRow In GvDescNCBonDetalle.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked AndAlso GvRow.DataKey("CveVenta").ToEntero() = Dr("CveVenta").ToString().ToEntero() Then
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidadRNC").Text.ToDecimal()
Dim PU = GvRow.DataKey("PU").ToDecimal()
Dim PorcentajeIVA As Decimal = GvRow.DataKey("PorcentajeIVA").ToDecimal()
Dim TotalCalculableImpuestos As Decimal = (Cantidad * PU)
Dim ImporteIVA As Decimal = (TotalCalculableImpuestos * PorcentajeIVA).RoundSQL(2)
Dim TotalRNCDetalle As Decimal = (TotalCalculableImpuestos + ImporteIVA)
TotalRNC += TotalRNCDetalle
If RemNC.CveVentaRNCCargo <= 0 Then
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVenta").ToEntero()
End If
End If
End If
Next
RemNC.TotalRemNCAplicado = TotalRNC
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)
If TerminarCiclo Then
Exit For
End If
Next
Else
For Each GvRow As GridViewRow In GvDescNCBonificaciones.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
@@ -30233,16 +30482,7 @@ Partial Class Ventas
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 'Bonificación' no debe superar el limite.<br/>Total RNC: {ListaNCBonificacion.Sum(Function(x) x.TotalRemNCAplicado):N2}.<br/>Total Usados: {LimiteUsados:N2}", TipoMensaje.MsgAdvertencia)
' ListaNCDesc.Clear()
' ListaNCBonificacion.Clear()
' Exit Sub
'End If
End If
ElseIf RblRNCTipoDesc.SelectedValue.Contiene("2") Then
@@ -31112,6 +31352,9 @@ Partial Class Ventas
DtVentasNC.Rows.Add(Drt)
DtVentasNC.AcceptChanges()
ObjFacturaProntoPago.DtVentasRelacionadas = New DataTable
ObjFacturaProntoPago.DtVentasRelacionadas.Columns.Add("CveVenta", GetType(Integer))
ObjFacturaProntoPago.DtVentasNC = DtVentasNC
Resp = ObjFacturaProntoPago.EmitirFactura(False, Transac:=SqlTransaccion, ObjContPaqTransac:=ObjConta)