Cambios BDH

This commit is contained in:
2020-11-28 08:17:56 -07:00
parent 73bc5171c7
commit d6e25967fa
6 changed files with 641 additions and 235 deletions

View File

@@ -454,6 +454,26 @@ Public Class ClsMovimientos
OnError("Ocurrió un error al consultar los Anticipos del Cliente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function GetRemisionesNCCliente(CveCliente As Integer, MostarDetalle As Boolean, Optional CveMoneda As Integer = -1, Optional CveClienteSucursal As Integer = -1) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_ClienteRemisionesNC")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveCliente", SqlDbType.Int).Value = CveCliente
.Add("@MostarDetalle", SqlDbType.Bit).Value = MostarDetalle
.Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal
.Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As SqlException
OnError("Ocurrió un error al consultar los Anticipos del Cliente.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function

View File

@@ -764,6 +764,25 @@ Public Class ClsVentas
Return Retorno
End Function
Public Function UpdateVentaRNCUsado(CveVentaRNC As Integer, CveVenta As Integer) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_VentasRNCUsadosUpdate")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVentaRNC", SqlDbType.Int).Value = CveVentaRNC
.Add("@CveVenta", SqlDbType.Int).Value = CveVenta
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError("Ocurrió un error al actualizar la relacion con el usado.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function UpdateCancelaVenta(CveVenta As Integer, FechaCancelacion As DateTime, SelloCancelacionSAT As String, CveEmpresa As Integer, Optional CvePAC As Integer = -1, Optional CveEstatusRefacturacion As Integer = 0) As Boolean
Dim Retorno As Boolean = False
@@ -4788,6 +4807,26 @@ Public Class ClsVentas
Return Retorno
End Function
Public Function AddVentaDetalleRNCFacturada(CveVentaDetalleRNC As Integer, CveVentaDetalle As Integer, CantidadFacturada As Decimal) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_VentaDetalleRNCFacturadaAdd")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVentaDetalleRNC", SqlDbType.Int).Value = CveVentaDetalleRNC
.Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVentaDetalle
.Add("@CantidadFacturada", SqlDbType.Float).Value = CantidadFacturada
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As SqlException
OnError("Ocurrió un error al agregar lo facturado de la RNC.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
#End Region

View File

@@ -2525,8 +2525,14 @@ Partial Class Inventarios_RecepcionUsados
If RblUsadosAjuste.SelectedValue = "1" Then
'agrego un registro extra del importe de ajuste
Dim PU As Decimal = TxtImporteAjuste.Text.ToDecimal
Dim CveSATNC As String = "84111506"
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("")
'CONSULTA EL CONCEPTO DE NC
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCAjuste As Integer = -1
If ArrayNC.Length > 5 Then
NCAjuste = ArrayNC(5).ToEntero()
End If
Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCAjuste, AplicaParaVenta:=1).FiltroPrimero("")
If Dr IsNot Nothing Then
Dim CveUnidadMedida, CveClasificacion, CvePS As Integer
@@ -2534,7 +2540,7 @@ Partial Class Inventarios_RecepcionUsados
CveClasificacion = Dr("CveClasificacion").ToString.ToEntero
CvePS = Dr("CvePS").ToString.ToEntero
Dim PorcentajeIVA As Decimal = 0.16D
Dim Obs As String = "Descuento por garantía"
Dim Obs As String = $"Descuento por garantía. BCI: {DdlBCIAjuste.SelectedValue}"
AddPSRNC(ObjRemisionNC.DtDetalle, 1, CveUnidadMedida, "", CveClasificacion, "", CvePS, "", Obs, PU, 0, -1, "",
ObjRemisionNC.CveSubProyecto, ObjRemisionNC.SubProyecto.SubProyecto, PorcentajeIVA:=PorcentajeIVA)
@@ -2806,13 +2812,6 @@ Partial Class Inventarios_RecepcionUsados
Dim ClasificacionPS As String = GlobalDTClasificaciones(CveEmpresa:=UsuarioActual.CveEmpresa, CveClasificacion:=CveClasificacionPS).FiltroPrimeroValor("Clasificacion").ToString()
Select Case TipoFolio
Case "GENERAL"
'20520 ACUM. AUTOMOTRIZ
'20522 ACUM. ESPECIALES
'20513 ACUM. ESTANDAR
'20521 ACUM. PESADO
'20512 ACUM. PREMIUM
'20514 ACUM. VALUE
'20229 Acumulador
ListaClasificacionesPermitidas.Add(20520) 'ACUM. AUTOMOTRIZ
ListaClasificacionesPermitidas.Add(20522) 'ACUM. ESPECIALES
ListaClasificacionesPermitidas.Add(20513) 'ACUM. ESTANDAR

View File

@@ -9161,7 +9161,7 @@ Partial Class Clientes
End If
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa, TxtFechaIUsados.Text.ToDate, TxtFechaFUsados.Text.ToDate) Then
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
GvUsadosResumen.DataSource = ObjAcum.DtResultados
End If
GvUsadosResumen.DataBind()

View File

@@ -2746,14 +2746,15 @@
<table>
<tr>
<td>Contrato:</td>
<td><asp:DropDownList ID="DdlContrato" runat="server" AppendDataBoundItems="true" Width="350px" AutoPostBack="true" DataTextField="NumeroContrato" DataValueField="CveContrato" CssClass="select2me" ></asp:DropDownList></td>
<td>
<asp:DropDownList ID="DdlContrato" runat="server" AppendDataBoundItems="true" Width="350px" AutoPostBack="true" DataTextField="NumeroContrato" DataValueField="CveContrato" CssClass="select2me"></asp:DropDownList></td>
</tr>
</table>
<asp:HyperLink ID="HLContrato" Target="_blank" CssClass="Texto" runat="server" Text="" Font-Bold="true"></asp:HyperLink>
<asp:GridView ID="GvEst" runat="server" AutoGenerateColumns="false" EmptyDataText="No se encontraron Estimaciones para este cliente" Width="100%" DataKeyNames="CveContrato,CveFamilias,CveSubFamilias,CveContratoAvance,Name,Importe,NumeroContrato,CveSubProyecto,FechaInicial" SelectedRowStyle-BackColor="#CCFF66" CssClass="table GvEst table-advance table-hover" Style="text-align: center;" GridLines="None">
<Columns>
@@ -2790,19 +2791,23 @@
<div id="ContratoDetalles" class="row" runat="server" visible="false">
<div class="col-md-12">
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<table>
<div class="row" style="margin-bottom: 10px;">
<div class="col-md-6">
<table>
<tr>
<td><asp:Label runat="server" Text="Contrato:"></asp:Label></td>
<td><asp:DropDownList runat="server" ID="DdlContratosModal" AutoPostBack="true" CssClass=" form-control input-sm select2me text-left" Width="400px" DataTextField="ContratoCompleto" DataValueField="CveContrato" /></td>
<td>
<asp:Label runat="server" Text="Contrato:"></asp:Label></td>
<td>
<asp:DropDownList runat="server" ID="DdlContratosModal" AutoPostBack="true" CssClass=" form-control input-sm select2me text-left" Width="400px" DataTextField="ContratoCompleto" DataValueField="CveContrato" /></td>
</tr>
<tr runat="server" id="DVEstimacionesObra" visible="false">
<td> Estimacion:</td>
<td> <asp:DropDownList ID="DdlEstimacionesObra" runat="server" AppendDataBoundItems="true" Width="400px" AutoPostBack="true" DataTextField="NumeroEstimacion" DataValueField="CveEstimacion" CssClass="select2me"></asp:DropDownList> </td>
<td>Estimacion:</td>
<td>
<asp:DropDownList ID="DdlEstimacionesObra" runat="server" AppendDataBoundItems="true" Width="400px" AutoPostBack="true" DataTextField="NumeroEstimacion" DataValueField="CveEstimacion" CssClass="select2me"></asp:DropDownList>
</td>
</tr>
</table>
</table>
</div>
@@ -2819,7 +2824,7 @@
<asp:ListItem Text="Venta" Value="2" Selected="True" />
<asp:ListItem Text="Suministro" Value="1" />
<%--<asp:ListItem Text="Consignación" Value="3" Enabled="false" />--%>
<asp:ListItem Text="Obra" Value="4" />
<asp:ListItem Text="Obra" Value="4" />
</asp:RadioButtonList>
</div>
<div class="col-md-6">
@@ -4314,7 +4319,7 @@
<asp:RadioButtonList ID="RblOpcionContrato" runat="server" CssClass="rbl" RepeatDirection="Horizontal" RepeatLayout="Table">
<asp:ListItem Text="Si" Value="2"></asp:ListItem>
<asp:ListItem Text="No" Value="1"></asp:ListItem>
</asp:RadioButtonList>
<asp:LinkButton ID="BtnIniciarContrato" runat="server" CssClass="btn btn-success" Text="Aceptar" />
@@ -6289,6 +6294,11 @@
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaRNCCargos','{0}')", GvRemisionesNC.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="ChkMostarProductosRNC" runat="server" AutoPostBack="true" Text="Mostrar Productos" OnCheckedChanged="ChkMostarProductosRNC_CheckedChanged" />
</div>
</div>
<div class="row" id="DivRNCCargos" runat="server" visible="false">
<div class="col-md-12" style="max-height: 440px; overflow: auto">
<asp:GridView ID="GvRemisionesNC" runat="server" AutoGenerateColumns="False"
DataKeyNames="CveVenta" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn" GridLines="None">
@@ -6320,6 +6330,35 @@
</asp:GridView>
</div>
</div>
<div class="row" id="DivRNCCargosDetalle" runat="server" visible="false">
<div class="col-md-12" style="max-height: 440px; overflow: auto">
<asp:GridView ID="GvRemisionesNCDetalle" 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" />
</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:Literal ID="TtlTotal" runat="server" Text='<%# Eval("Total", "{0:N2}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
<div class="row" id="DivSMU" runat="server" visible="false">
<div class="col-md-12">
<table border="0" rules="none" class="well TextTab" style="float: right;" runat="server">
@@ -6439,7 +6478,7 @@
<div class="col-md-2">
<asp:Button ID="BtnCalcularPenalizacion" runat="server" CssClass="btn btn-primary btn-sm" Text="Calcular" OnClick="BtnCalcularPenalizacion_Click" />
</div>
<div class="col-md-6"> </div>
<div class="col-md-6"></div>
</div>
<div class="row" style="margin-bottom: 10px;">
<div class="text-right col-md-offset-8 col-md-4">
@@ -7988,65 +8027,65 @@
}
function FnCambiaAnt(chk, txt, saldo) {
debugger;
function FnCambiaAnt(chk, txt, saldo) {
debugger;
var Total = ToDouble($get('TxtSubTotal').value);
let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
let importeTxt = parseFloat(txt.value.replace(/,/g, ''));
var Total = ToDouble($get('TxtSubTotal').value);
let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
let importeTxt = parseFloat(txt.value.replace(/,/g, ''));
if (isNaN(importeTxt)) {
importeTxt = 0;
} else {
if (importeTxt <= 0) {
if (isNaN(importeTxt)) {
importeTxt = 0;
chk.checked = false;
return;
} else {
if (importeTxt <= 0) {
importeTxt = 0;
chk.checked = false;
return;
}
}
saldo = (importeTxt > saldo) ? saldo : importeTxt;
var SaldoCompra = (Total - FnSumaValoresAnt() + ToDouble(txt.value)).toFixed(2); // le agrego lo del valor actual para validarlo //parseFloat(parseFloat($get('HdnVentaSaldo').value).toFixed(2));
if (SaldoCompra < 0) txt.value = SaldoCompra - txt.value;
//minimo entre saldocompra y el saldoanticipo
if (SaldoCompra < saldo) saldo = SaldoCompra;
if (ToDouble(txt.value) > 0) {
chk.checked = true;
} else {
chk.checked = false;
}
if (ToDouble(txt.value) > saldo) {
txt.value = saldo;
alert("El Importe no debe de exceder a el saldo");
}
$("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
$get('HdnVentaSaldo').value = Total - FnSumaValoresAnt();
}
saldo = (importeTxt > saldo) ? saldo : importeTxt;
function FnSumaValoresAnt() {
debugger;
var totalPoints = 0;
var t = '';
$('input[name*=TxtAnticipo]').each(function () {
totalPoints += ToDouble($(this).val());
});
var SaldoCompra = (Total - FnSumaValoresAnt() + ToDouble(txt.value)).toFixed(2); // le agrego lo del valor actual para validarlo //parseFloat(parseFloat($get('HdnVentaSaldo').value).toFixed(2));
if (SaldoCompra < 0) txt.value = SaldoCompra - txt.value;
//minimo entre saldocompra y el saldoanticipo
if (SaldoCompra < saldo) saldo = SaldoCompra;
if (ToDouble(txt.value) > 0) {
chk.checked = true;
} else {
chk.checked = false;
return Math.round(totalPoints * 100) / 100;
}
if (ToDouble(txt.value) > saldo) {
txt.value = saldo;
alert("El Importe no debe de exceder a el saldo");
}
$("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
$get('HdnVentaSaldo').value = Total - FnSumaValoresAnt();
}
function FnSumaValoresAnt() {
debugger;
var totalPoints = 0;
var t = '';
$('input[name*=TxtAnticipo]').each(function () {
totalPoints += ToDouble($(this).val());
});
return Math.round(totalPoints * 100) / 100;
}
function LimpiaModal() {
$('#<%= TxtDireccion.ClientID %>').val('');
function LimpiaModal() {
$('#<%= TxtDireccion.ClientID %>').val('');
$('#<%= TxtColonia.ClientID %>').val('');
$('#<%= TxtCiudad.ClientID %>').val('');
$('#<%= TxtEstado.ClientID %>').val('');
@@ -8271,68 +8310,68 @@
function ConvertirDolares(ChkConvertirDolares) {
//LIMPIA
$('#<%= LblDolaresConvertidos.ClientID %>').text('');
$("#TrConversionDolaresTexto").hide();
$("#TrConversionDolaresTexto").hide();
//CALCULA
if (ChkConvertirDolares.checked) {
ConvertirPesosDlls();
}
}
//CALCULA
if (ChkConvertirDolares.checked) {
ConvertirPesosDlls();
}
}
//FUNCIONES PARA MODAL "ModalAplicarNC"
function CalculaImporteNC() {
var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value));
//var ImporteReferencia = ToDouble($get('TxtTotal').value);
//FUNCIONES PARA MODAL "ModalAplicarNC"
function CalculaImporteNC() {
var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value));
//var ImporteReferencia = ToDouble($get('TxtTotal').value);
$get('TxtNCImporte').value = FormatoNumero((ToDouble($get('TxtNCPorcentaje').value) * ImporteReferencia) / 100, 2);
}
$get('TxtNCImporte').value = FormatoNumero((ToDouble($get('TxtNCPorcentaje').value) * ImporteReferencia) / 100, 2);
}
function CalculaPorcentajeNC() {
var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value));
//var ImporteReferencia = ToDouble($get('TxtTotal').value);
$get('TxtNCPorcentaje').value = FormatoNumero((ToDouble($get('TxtNCImporte').value) * 100) / ImporteReferencia, 4);
}
function CalculaPorcentajeNC() {
var ImporteReferencia = (($('#C_DdlNCNivelImporte').val() == "1") ? ToDouble($get('TxtTotal').value) : ToDouble($get('TxtSubTotal').value));
//var ImporteReferencia = ToDouble($get('TxtTotal').value);
$get('TxtNCPorcentaje').value = FormatoNumero((ToDouble($get('TxtNCImporte').value) * 100) / ImporteReferencia, 4);
}
function CambioTipoMoneda(chk, saldo, txt, tipocambio, CveMoneda) {
debugger;
if (tipocambio.value.length > 0) {
function CambioTipoMoneda(chk, saldo, txt, tipocambio, CveMoneda) {
debugger;
if (tipocambio.value.length > 0) {
if (CveMoneda == 1) {
txt.value = FormatoNumero(ToDouble(saldo / tipocambio.value), 2);
} else {
txt.value = FormatoNumero(ToDouble(saldo * tipocambio.value), 2);
if (CveMoneda == 1) {
txt.value = FormatoNumero(ToDouble(saldo / tipocambio.value), 2);
} else {
txt.value = FormatoNumero(ToDouble(saldo * tipocambio.value), 2);
}
}
}
}
}
}
function BuscarOCRegistrada() {
$('#btnBuscarOCRegistrada').click();
}
function BuscarOCRegistrada() {
$('#btnBuscarOCRegistrada').click();
}
function ValidaAnticipoBoton() {
function ValidaAnticipoBoton() {
var Descuentototal = ToDouble($('#LblDescuentos').text()).toFixed(2);
var TotalAnticipos = ToDouble($('#LblTotalAnticipos').text()).toFixed(2);
var Descuentototal = ToDouble($('#LblDescuentos').text()).toFixed(2);
var TotalAnticipos = ToDouble($('#LblTotalAnticipos').text()).toFixed(2);
var IndexActualDdl = parseInt($('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').prop('selectedIndex'));
var IndexActualDdl = parseInt($('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').prop('selectedIndex'));
if (IndexActualDdl == 1 && IndexActualDd2 > 0 && TotalAnticipos > 0) {
if (TotalAnticipos > 0) {
$('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', false);
} else {
$('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true);
}
} else {
$('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true);
}
} else {
$('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true);
}
} else {
$('#<%= BtnAceptarAnticipos.ClientID %>').prop('disabled', true);
}
}
}
function showDivEC() {
$('#<%= TxtRFCCliente.ClientID %>').val('');
function showDivEC() {
$('#<%= TxtRFCCliente.ClientID %>').val('');
$('#<%= TxtNombreCliente.ClientID %>').val('');
$('#<%= TxtDireccionCliente.ClientID %>').val('');
$('#<%= TxtNumExtCliente.ClientID %>').val('');

View File

@@ -144,6 +144,22 @@ Partial Class Ventas
ViewState("TmpDTRNCBonificacionesSeleccionadas") = value
End Set
End Property
Private Property TmpDTRNCDetalle As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCDetalle")), Nothing, CType(ViewState("TmpDTRNCDetalle"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCDetalle") = value
End Set
End Property
Private Property TmpDTRNCDetalleSelecciondas As DataTable
Get
Return If(IsNothing(ViewState("TmpDTRNCDetalleSelecciondas")), Nothing, CType(ViewState("TmpDTRNCDetalleSelecciondas"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTRNCDetalleSelecciondas") = value
End Set
End Property
Private Property TmpDTError As DataTable
Get
Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable))
@@ -1861,6 +1877,22 @@ Partial Class Ventas
ViewState("SerieVenta") = value
End Set
End Property
Private Property AplicaDocumentoNuevoNC As Boolean
Get
Return CBool(IfNull(ViewState("AplicaDocumentoNuevoNC"), "False", ViewState("AplicaDocumentoNuevoNC")))
End Get
Set(value As Boolean)
ViewState("AplicaDocumentoNuevoNC") = value
End Set
End Property
Private Property AplicaRNCXDetalle As Boolean
Get
Return CBool(IfNull(ViewState("AplicaRNCXDetalle"), "False", ViewState("AplicaRNCXDetalle")))
End Get
Set(value As Boolean)
ViewState("AplicaRNCXDetalle") = value
End Set
End Property
#End Region
@@ -3928,6 +3960,7 @@ Partial Class Ventas
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
@@ -5617,7 +5650,7 @@ Partial Class Ventas
Dim ObjClientes As New ClsClientes
If ObjClientes.GetHistorialVentas(CveCliente, 1000, CveClienteSucursal:=-1, TipoDocto:="Ing", CveEstatusFactura:=-1, FechaI:=Now.AddMonths(-1)) Then
DdlVentaUsado.DataSource = ObjClientes.DtResultados
DdlVentaUsado.DataSource = ObjClientes.DtResultados.FiltraParametros("UsadoMarcado = 0")
End If
ObjClientes.Dispose()
@@ -8575,7 +8608,7 @@ Partial Class Ventas
End If
'SI NO ES REFACTURACION
If NuevaFactura <> 1 Then
If NuevaFactura <> 1 AndAlso Not AplicaDocumentoNuevoNC Then
If DtVentasNC Is Nothing Then InicializaDTVentasNC()
Dim Drt = DtVentasNC.NewRow
Drt("CveVenta") = ObjFactura.CveVenta
@@ -10497,6 +10530,15 @@ Partial Class Ventas
Catch ex As Exception
End Try
'SI SE FACTURA UNA RNC SE MUESTRA
If UsuarioActual.CveEmpresa = 140 AndAlso factura.TipoDocto = "Egs" Then
If Row("CveVentaDetalleRNC").ToString().ToEntero() > 0 Then
If Not ObjVentas.AddVentaDetalleRNCFacturada(Row("CveVentaDetalleRNC").ToString().ToEntero(), ObjVentas.CveVentaDetalle, Row("Cantidad").ToString().ToDecimal()) Then
ErrorList.Add("Ocurrió un error al agregar la venta detalle devolución.")
End If
End If
End If
End If
Next
@@ -11589,6 +11631,13 @@ Partial Class Ventas
CveCuenta = ObjFactura.Cliente.CveCuentaMonedaExtranjera
End If
'ACTUALIZA SI LA VENTA FUE MARCADA CON OTRA PARA EL FILTRO DE USADOS
If ObjRNC.Num3 > 0 Then
If Not ObjVentas.UpdateVentaRNCUsado(ObjRNC.CveVenta, ObjRNC.Num3.ToEntero()) Then
ErrorPrepoliza = True
End If
End If
IdCtaContableCliente = IdCtaContable
CveCuentaCliente = CveCuenta
@@ -16508,6 +16557,7 @@ Partial Class Ventas
TmpDT.Columns.Add("EsOutSourcing", GetType(Boolean))
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns("EsOutSourcing").DefaultValue = False
TmpDT.Columns("EsCargo").DefaultValue = False
@@ -23570,6 +23620,18 @@ Partial Class Ventas
ObjMovtos.Dispose()
GvCxC.DataBind()
End Sub
Protected Sub ChkMostarProductosRNC_CheckedChanged(sender As Object, e As EventArgs)
If ChkMostarProductosRNC.Checked Then
DivRNCCargos.Visible = False
DivRNCCargosDetalle.Visible = True
CargaRNCDetalle(DdlVentaUsado.SelectedValue.ToEntero())
Else
DivRNCCargos.Visible = True
DivRNCCargosDetalle.Visible = False
CargaRNC(DdlVentaUsado.SelectedValue.ToEntero())
End If
UpModalRemisionesNC.Update()
End Sub
Private Sub CargaRNC(Optional CveVentaUsado As Integer = -1)
Dim DtNC As DataTable = Nothing
@@ -23603,8 +23665,58 @@ Partial Class Ventas
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
HdnSaldoMaximoUsados.Value = RowUsadosNC("Valor").ToString()
LtlSMU.Text = RowUsadosNC("Valor").ToString().ToDecimal().FormatoNumero(2)
HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString()
LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2)
Else
DivSMU.Visible = False
HdnSaldoMaximoUsados.Value = "0"
LtlSMU.Text = "0"
End If
ObjAcum.Dispose()
End If
UpModalRemisionesNC.Update()
UpDescNC.Update()
End Sub
Private Sub CargaRNCDetalle(Optional CveVentaUsado As Integer = -1)
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
Me.TmpDTRNCDetalle = ObjMovtos.DtResultados.Copy()
End If
ObjMovtos.Dispose()
Me.TmpDTRNCDetalle.Columns.Add(New DataColumn("CveVentaDetalleNCGenerada", GetType(Integer)))
Me.TmpDTRNCDetalleSelecciondas = Nothing
Me.TmpDTRNCDetalleSelecciondas = TmpDTRNCDetalle.Clone()
Me.TmpDTRNCDetalleSelecciondas.Clear()
GvRemisionesNCDetalle.DataSource = TmpDTRNCDetalle.FiltraParametros("TipoRNC = 1")
'GvRemisionesNCBon.DataSource = TmpDTRNCBonificacionesSeleccionadas
'Me.TmpDTRNCBonificacionesCliente = DtNC.FiltraParametros("TipoRNC = 2")
'Me.TmpDTRNCBonificacionesCliente.Columns.Add("ImporteBonificacion", GetType(Decimal))
'Me.TmpDTRNCBonificacionesCliente.Columns.Add("IVABonificacion", GetType(Decimal))
'Me.TmpDTRNCBonificacionesCliente.Columns.Add("CveVentaRNCCargo", GetType(Integer))
GvRemisionesNCDetalle.DataBind()
'GvRemisionesNCBon.DataBind()
If CveVentaUsado > 0 Then
DivSMU.Visible = True
Dim FacUsado As New Modelos.Factura(UsuarioActual, CveVentaUsado, UsuarioActual.CveEmpresa)
Dim SaldoMaximoUsados As Decimal = FacUsado.DtDetalle.SUM("Total", "EsCargo = True").ToDecimal() + FacUsado.DtDetalle.SUM("ImporteIVA", "EsCargo = True").ToDecimal()
HdnSaldoMaximoUsados.Value = SaldoMaximoUsados.ToString()
LtlSMU.Text = String.Format("{0:N2}", SaldoMaximoUsados)
Else
Dim ObjAcum As New ClsAcumuladores
If ObjAcum.GetMovimientosDistribuidorResumen(CveCliente, UsuarioActual.CveEmpresa) Then
Dim RowUsadosNC As DataRow = ObjAcum.DtResultados.Rows(2)
DivSMU.Visible = True
HdnSaldoMaximoUsados.Value = RowUsadosNC("ValorConImpuestos").ToString()
LtlSMU.Text = RowUsadosNC("ValorConImpuestos").ToString().ToDecimal().FormatoNumero(2)
Else
DivSMU.Visible = False
HdnSaldoMaximoUsados.Value = "0"
@@ -23814,6 +23926,15 @@ Partial Class Ventas
e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);")
End If
End Sub
Protected Sub GvRemisionesNCDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRemisionesNCDetalle.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
End If
End If
End Sub
Protected Sub DdlNCNivelImporte_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim ImporteReferencia As Double = 0, PorcentajeMaximo As Double = 0
@@ -23842,7 +23963,7 @@ Partial Class Ventas
'SOLO APLICA SI NO HAY DOCUMENTOS QUE SELECCIONAR
If UsuarioActual.CveEmpresa = 140 Then
If GvCxC.Rows.Count = 0 OrElse GvCxC.Rows.Cast(Of GridViewRow)().Count(Function(gvr) gvr.FCCheckBox("ChkCxC").Checked) = 0 Then
Alert("No se ha seleccionado ninguna nota de crédito, en caso de no seleccionar ninguna se creará una nueva nota de crédito. ¿Está seguro de realizar esta acción?", TipoMensaje.MsgConfirmacion, JSBtnAceptar:="BtnAplicaNuevaNC();", TextoConfirmacion:="&nbsp;&nbsp;&nbsp;&nbsp;Si&nbsp;&nbsp;&nbsp;&nbsp;", TextoCancelacion:="&nbsp;&nbsp;&nbsp;&nbsp;No&nbsp;&nbsp;&nbsp;&nbsp;")
Alert("No se ha seleccionado ninguna factura, en caso de no seleccionar ninguna se creará una nueva nota de crédito. ¿Está seguro de realizar esta acción?", TipoMensaje.MsgConfirmacion, JSBtnAceptar:="BtnAplicaNuevaNC();", TextoConfirmacion:="&nbsp;&nbsp;&nbsp;&nbsp;Si&nbsp;&nbsp;&nbsp;&nbsp;", TextoCancelacion:="&nbsp;&nbsp;&nbsp;&nbsp;No&nbsp;&nbsp;&nbsp;&nbsp;")
Else
AplicarNotaCreditoDesdeVenta()
End If
@@ -23898,6 +24019,7 @@ Partial Class Ventas
Private Sub AplicarNC(CvePS As Integer, Optional NCDescuento As Boolean = False, Optional EsNCAmortizacion As Boolean = False, Optional AplicaImpuestosLocales As Boolean = True, Optional AplicaNuevoDocumento As Boolean = False, Optional AplicoNCFacturaActual As Boolean = False)
Try
Me.AplicaDocumentoNuevoNC = AplicaNuevoDocumento
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("")
If DrPS Is Nothing Then
Alert("Ocurrió un error al cargar la información del producto. Por favor comuniquese con asistencia SIG", TipoMensaje.MsgError)
@@ -24066,11 +24188,22 @@ Partial Class Ventas
TmpDTDescNC.Clear()
If UsuarioActual.CveEmpresa = 140 Then
If AplicaRNCXDetalle Then
CrearDTNCCargoDetalle(ListaNCDesc, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
Else
CrearDTNCCargo(ListaNCDesc, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
End If
CrearDTNCCargo(ListaNCDesc, DtImpuestos, TmpDTDescNC, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
'CONSULTA EL CONCEPTO DE NC
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCBonificacion As Integer = 0
If ArrayNC.Length > 4 Then
NCBonificacion = ArrayNC(4).ToEntero()
End If
'EN LA NC DE BONIFICACION EL CONCEPTO DEBE SER SIEMPRE 'BONIFICACION POR USADO'
Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=360481).FiltroPrimero("")
Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCBonificacion).FiltroPrimero("")
If DrPSBonificacion IsNot Nothing Then
CrearDTNCBonificacion(ListaNCDesc, DtImpuestosBonificacion, TmpDTDescNC, DrPSBonificacion, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
Else
@@ -24107,9 +24240,20 @@ Partial Class Ventas
'DEBE AGREGAR LOS USADOS DE LA REMISION EN LA NOTA DE CREDITO
If UsuarioActual.CveEmpresa = 140 AndAlso (ListaRemisionesNC IsNot Nothing AndAlso ListaRemisionesNC.Count > 0) Then
CrearDTNCCargo(ListaRemisionesNC, DtImpuestos, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
If AplicaRNCXDetalle Then
CrearDTNCCargoDetalle(ListaRemisionesNC, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
Else
CrearDTNCCargo(ListaRemisionesNC, TmpDT, DrPS, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
End If
'EN LA NC DE BONIFICACION EL CONCEPTO DEBE SER SIEMPRE 'BONIFICACION POR USADO'
Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=360481).FiltroPrimero("")
'CONSULTA EL CONCEPTO DE NC
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCBonificacion As Integer = 0
If ArrayNC.Length > 4 Then
NCBonificacion = ArrayNC(4).ToEntero()
End If
Dim DrPSBonificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCBonificacion).FiltroPrimero("")
If DrPSBonificacion IsNot Nothing Then
CrearDTNCBonificacion(ListaRemisionesNC, DtImpuestosBonificacion, TmpDT, DrPSBonificacion, CveProyecto, Proyecto, CveSubProyecto, SubProyecto)
Else
@@ -24170,42 +24314,104 @@ Partial Class Ventas
UPCondicionesPago.Update()
End Sub
Private Sub CrearDTNCCargo(ListaNC As List(Of Modelos.Factura), DtImpuestos As DataTable, ByRef TmpDTCargo As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String)
For Each Dr As DataRow In DtImpuestos.Rows
For Each RNC In ListaNC
Dim UltimoRenglonRNC As Integer = 1
For Each RowUsado As DataRow In RNC.DtDetalle.Rows
Private Sub CrearDTNCCargo(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)
For Each RNC In ListaNC
Dim UltimoRenglonRNC As Integer = 1
Dim TotalAcumuladoRNC As Decimal = 0
Dim PorcentajeUsado = ((RowUsado("Total").ToString().ToDecimal() - RowUsado("Descuento").ToString().ToDecimal() + RowUsado("ImporteIVA").ToString().ToDecimal() + RowUsado("ImporteIEPS").ToString().ToDecimal() - RowUsado("ImporteRetIVA").ToString().ToDecimal() - RowUsado("ImporteRetISR").ToString().ToDecimal()) / RNC.Total) / ListaNC.Count
Dim Obs = RowUsado("CodigoPS").ToString()
For Each RowUsado As DataRow In RNC.DtDetalle.Rows
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim())
Dim PorcentajeAplicado = (RNC.TotalRemNCAplicado / RNC.Total)
Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal() * PorcentajeAplicado
Dim Obs = RowUsado("CodigoPS").ToString()
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 = (TotalCalculableImpuestos * RowUsado("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2)
Dim ImporteRetIVA = (TotalCalculableImpuestos * RowUsado("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2)
Dim ImporteRetISR = (TotalCalculableImpuestos * RowUsado("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2)
Dim ImporteTotal = TotalCalculableImpuestos
TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR)
'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE
If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count 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
Dim ImportePU = Dr("ImportePU").ToString().ToDecimal * PorcentajeUsado
Dim ImporteIVA = Dr("ImporteIVA").ToString().ToDecimal * PorcentajeUsado
Dim ImporteRetIVA = Dr("ImporteRetIVA").ToString().ToDecimal * PorcentajeUsado
Dim ImporteRetISR = Dr("ImporteRetISR").ToString().ToDecimal * PorcentajeUsado
Dim ImporteIEPS = Dr("ImporteIEPS").ToString().ToDecimal * PorcentajeUsado
Dim ImporteTotal = Dr("ImporteTotal").ToString().ToDecimal * PorcentajeUsado
'If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count Then
' ImportePU += Ajuste
'End If
AgregaTempDT(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(),
AgregaTempDT(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(),
DrPS("CveUM").ToString().ToEntero(), DrPS("UnidadMedida").ToString(), DrPS("CveClasificacion").ToString().ToEntero(), DrPS("Clasificacion").ToString(), CveProyecto, Proyecto, CveSubProyecto, SubProyecto,
Obs, 1, ImportePU, Dr("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, Dr("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA,
Dr("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, Dr("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1,
DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1)
UltimoRenglonRNC += 1
Next
Obs, Cantidad, ImportePU, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, RowUsado("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA,
RowUsado("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, RowUsado("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1,
DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalle").ToString().ToEntero())
Next
Next
End Sub
Private Sub CrearDTNCCargoDetalle(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)
For Each RNC In ListaNC
Dim UltimoRenglonRNC As Integer = 1
Dim TotalAcumuladoRNC As Decimal = 0
For Each RowUsado As DataRow In Me.TmpDTRNCDetalleSelecciondas.FiltraParametros($"CveVenta={RNC.CveVenta}").Rows
Dim Cantidad As Decimal = RowUsado("Cantidad").ToString().ToDecimal()
Dim Obs = RowUsado("CodigoPS").ToString()
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 ES EL ULTIMO REGLON REALIZA UN AJUSTE
If UltimoRenglonRNC = RNC.DtDetalle.Rows.Count 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(TmpDTCargo, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(),
DrPS("CveUM").ToString().ToEntero(), DrPS("UnidadMedida").ToString(), DrPS("CveClasificacion").ToString().ToEntero(), DrPS("Clasificacion").ToString(), CveProyecto, Proyecto, CveSubProyecto, SubProyecto,
Obs, Cantidad, ImportePU, RowUsado("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, 0, ImporteRetIVA,
0, ImporteRetISR, 0, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1,
DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1, CveVentaDetalleRNC:=RowUsado("CveVentaDetalleRNC").ToString().ToEntero())
Next
Next
End Sub
Private Sub CrearDTNCBonificacion(ListaNC As List(Of Modelos.Factura), DtImpuestosBonificacion As DataTable, ByRef TmpDTNC As DataTable, DrPS As DataRow, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String)
'SI TIENE DE BONIFICACION LOS AGREGA
If DtImpuestosBonificacion IsNot Nothing AndAlso ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0 Then
@@ -24213,39 +24419,54 @@ Partial Class Ventas
TmpDTDescNCBonificacion = TmpDTNC.Clone()
TmpDTDescNCBonificacion.Clear()
For Each Dr As DataRow In DtImpuestosBonificacion.Rows
For Each RNC In ListaNCBonificacion
Dim UltimoRenglonRNC As Integer = 1
For Each RNCBonificacion In ListaNCBonificacion
Dim UltimoRenglonRNC As Integer = 1
Dim TotalAcumuladoRNC As Decimal = 0
Dim RNCCargo = ListaNC.Where(Function(f) f.CveVenta = RNC.CveVentaRNCCargo).FirstOrDefault()
Dim RNCCargo = ListaNC.Where(Function(f) f.CveVenta = RNCBonificacion.CveVentaRNCCargo).FirstOrDefault()
For Each RowCargo As DataRow In RNCCargo.DtDetalle.Rows
For Each RowCargo As DataRow In RNCCargo.DtDetalle.Rows
Dim PorcentajeCargo = ((RowCargo("Total").ToString().ToDecimal() - RowCargo("Descuento").ToString().ToDecimal() + RowCargo("ImporteIVA").ToString().ToDecimal() + RowCargo("ImporteIEPS").ToString().ToDecimal() - RowCargo("ImporteRetIVA").ToString().ToDecimal() - RowCargo("ImporteRetISR").ToString().ToDecimal()) / RNCCargo.Total) / ListaNCBonificacion.Count
Dim PorcentajeAplicado = (RNCBonificacion.TotalRemNCAplicado / RNCBonificacion.Total)
Dim Obs = RowCargo("CodigoPS").ToString()
Dim Cantidad As Decimal = RowCargo("Cantidad").ToString().ToDecimal() * PorcentajeAplicado
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim())
Dim Obs = RowCargo("CodigoPS").ToString()
If Not String.IsNullOrEmpty(TxtNCObservaciones.Text.Trim()) Then
Obs = String.Format("{0} - {1}", Obs, TxtNCObservaciones.Text.Trim())
End If
Dim ImportePU = RowCargo("PUBonificacion").ToString().ToDecimal
Dim TotalCalculableImpuestos As Decimal = (Cantidad * ImportePU)
Dim ImporteIVA = (TotalCalculableImpuestos * RowCargo("PorcentajeIVA").ToString().ToDecimal).RoundSQL(2)
Dim ImporteIEPS = (TotalCalculableImpuestos * RowCargo("PorcentajeIEPS").ToString().ToDecimal).RoundSQL(2)
Dim ImporteRetIVA = (TotalCalculableImpuestos * RowCargo("PorcentajeRetIVA").ToString().ToDecimal).RoundSQL(2)
Dim ImporteRetISR = (TotalCalculableImpuestos * RowCargo("PorcentajeRetISR").ToString().ToDecimal).RoundSQL(2)
Dim ImporteTotal = TotalCalculableImpuestos
TotalAcumuladoRNC += (TotalCalculableImpuestos + ImporteIVA + ImporteIEPS - ImporteRetIVA - ImporteRetISR)
'SI ES EL ULTIMO REGLON REALIZA UN AJUSTE
If UltimoRenglonRNC = RNCCargo.DtDetalle.Rows.Count Then
Dim Ajuste As Decimal = 0
If Math.Abs(RNCBonificacion.TotalRemNCAplicado - TotalAcumuladoRNC) > 0.00 Then
Ajuste = RNCBonificacion.TotalRemNCAplicado - TotalAcumuladoRNC
ImporteIVA += Ajuste
End If
End If
UltimoRenglonRNC += 1
Dim ImportePU = Dr("ImportePU").ToString().ToDecimal * PorcentajeCargo
Dim ImporteIVA = Dr("ImporteIVA").ToString().ToDecimal * PorcentajeCargo
Dim ImporteRetIVA = Dr("ImporteRetIVA").ToString().ToDecimal * PorcentajeCargo
Dim ImporteRetISR = Dr("ImporteRetISR").ToString().ToDecimal * PorcentajeCargo
Dim ImporteIEPS = Dr("ImporteIEPS").ToString().ToDecimal * PorcentajeCargo
Dim ImporteTotal = Dr("ImporteTotal").ToString().ToDecimal * PorcentajeCargo
AgregaTempDT(TmpDTDescNCBonificacion, DrPS("CvePS").ToString().ToEntero(), DrPS("PS").ToString(), DrPS("Codigo").ToString(), DrPS("PSCodigo").ToString(), DrPS("CveTipoPS").ToString().ToEntero(), DrPS("Inv_CveMetodoInventario").ToString().ToEntero(),
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, 1, ImportePU, Dr("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, Dr("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA,
Dr("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, Dr("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1,
Obs, Cantidad, ImportePU, RowCargo("PorcentajeIVA").ToString().ToDecimal, ImporteIVA, RowCargo("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA,
RowCargo("PorcentajeRetISR").ToString().ToDecimal, ImporteRetISR, RowCargo("PorcentajeIEPS").ToString().ToDecimal, ImporteIEPS, -1, 0.0, ImporteTotal, "", "", -1, -1,
DrPS("SATClavePS").ToString(), DrPS("SATClaveUnidadMedida").ToString(), -1, -1, -1, -1, -1, -1)
UltimoRenglonRNC += 1
Next
Next
Next
End If
End Sub
@@ -24360,7 +24581,7 @@ Partial Class Ventas
PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double,
Total As Double, Serie As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String,
SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer,
CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer, Optional CveTamaño As Integer = -1)
CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer, Optional CveTamaño As Integer = -1, Optional CveVentaDetalleRNC As Integer = -1)
Dim Row As DataRow = Nothing
Row = TmpDT.NewRow()
@@ -24420,6 +24641,7 @@ Partial Class Ventas
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
Row("CveTamaño") = CveTamaño
Row("CveVentaDetalleRNC") = CveVentaDetalleRNC
TmpDT.Rows.Add(Row)
End Sub
@@ -27235,6 +27457,8 @@ 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
If ListaRemisionesNC Is Nothing Then
ListaRemisionesNC = New List(Of Modelos.Factura)
Else
@@ -27248,69 +27472,139 @@ Partial Class Ventas
End If
Dim TotalRemNCAplicado As Decimal = 0
For Each GvRow As GridViewRow In GvRemisionesNC.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
If RemNC.TotalRemNCAplicado <= 0 Then
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
ListaRemisionesNC.Clear()
Exit Sub
If ChkMostarProductosRNC.Checked Then
Me.AplicaRNCXDetalle = True
For Each GvRow As GridViewRow In GvRemisionesNCDetalle.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim Rows = TmpDTRNCDetalle.Select($"CveVentaDetalleRNC = {GvRow.DataKey("CveVentaDetalleRNC").ToEntero()}")
For Each row In Rows
row("Cantidad") = GvRow.FCTextBox("TxtCantidadRNC").Text.ToEntero()
TmpDTRNCDetalleSelecciondas.Rows.Add(row.ItemArray)
Next
End If
ListaRemisionesNC.Add(RemNC)
End If
End If
Next
'SI TIENE ALGUN AJUSTE O GARANTIA
If ListaRemisionesNC.Any(Function(RNC) RNC.Num2 = 1) Then
For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1)
Dim Salir As Boolean = False
Using ObjAcum As New ClsAcumuladores
If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then
'SI ES GARANTIA TOTAL
If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then
DdlNCPS.SelectedValueExist(443174)
DdlNCPS.Enabled = False
Salir = True
Else
DdlNCPS.SelectedValueExist(443173)
DdlNCPS.Enabled = False
End If
End If
End Using
If Salir Then
Exit For
End If
Next
For Each Dr As DataRow In TmpDTRNCDetalleSelecciondas.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 GvRemisionesNCDetalle.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
End If
End If
Next
RemNC.TotalRemNCAplicado = TotalRNC
'MARCA LA VENTA QUE FUE USADA PARA EL FILTRO
RemNC.Num3 = DdlVentaUsado.SelectedValue.ToEntero()
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
If RemNC.TotalRemNCAplicado <= 0 Then
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
ListaRemisionesNC.Clear()
Exit Sub
End If
ListaRemisionesNC.Add(RemNC)
Next
Else
DdlNCPS.Enabled = True
End If
For Each GvRow As GridViewRow In GvRemisionesNC.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()
'MARCA LA VENTA QUE FUE USADA PARA EL FILTRO
RemNC.Num3 = DdlVentaUsado.SelectedValue.ToEntero()
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero()
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
If RemNC.TotalRemNCAplicado <= 0 Then
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
ListaRemisionesNC.Clear()
Exit Sub
End If
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
ListaRemisionesNC.Add(RemNC)
End If
End If
Next
'SI TIENE ALGUN AJUSTE O GARANTIA
If ListaRemisionesNC.Any(Function(RNC) RNC.Num2 = 1) Then
For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1)
Dim Salir As Boolean = False
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCAjuste As Integer = -1
Dim NCGarantiaTotal As Integer = -1
If ArrayNC.Length > 2 Then
NCAjuste = ArrayNC(1).ToEntero()
NCGarantiaTotal = ArrayNC(2).ToEntero()
End If
ListaNCBonificacion.Add(RemNC)
End If
Using ObjAcum As New ClsAcumuladores
If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then
'SI ES GARANTIA TOTAL
If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then
DdlNCPS.SelectedValueExist(NCGarantiaTotal)
DdlNCPS.Enabled = False
Salir = True
Else
DdlNCPS.SelectedValueExist(NCAjuste)
DdlNCPS.Enabled = False
End If
End If
End Using
If Salir Then
Exit For
End If
Next
Else
DdlNCPS.Enabled = True
End If
Next
For Each GvRow As GridViewRow In GvRemisionesNCBon.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.FCCheckBox("ChkAplicar").Checked Then
Dim RemNC As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa)
RemNC.TotalRemNCAplicado = GvRow.FCTextBox("TxtImporte").Text.ToDecimal()
RemNC.CveVentaRNCCargo = GvRow.DataKey("CveVentaRNCCargo").ToEntero()
TotalRemNCAplicado += RemNC.TotalRemNCAplicado
If RemNC.TotalRemNCAplicado <= 0 Then
Alert($"Debe asignar un importe en la siguiente remisión: <b>{RemNC.SerieFolio}</b>", TipoMensaje.MsgAdvertencia)
ListaNCBonificacion.Clear()
Exit Sub
End If
ListaNCBonificacion.Add(RemNC)
End If
End If
Next
End If
TxtImportesRemisionesNC.Text = TotalRemNCAplicado.FormatoNumero
TxtNCImporte.Text = TotalRemNCAplicado.FormatoNumero
@@ -27330,6 +27624,12 @@ Partial Class Ventas
Dim CveSATNC = "84111506"
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).Rows(0)
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
If ArrayNC.Length > 0 Then
Dim CvePSNC As Integer = ArrayNC(0).ToEntero()
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSNC, AplicaParaVenta:=1).Rows(0)
End If
If DrPS Is Nothing Then
Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
Exit Sub
@@ -27372,14 +27672,22 @@ Partial Class Ventas
If ListaNCDesc.Any(Function(RNC) RNC.Num2 = 1) Then
For Each RNC In ListaRemisionesNC.Where(Function(x) x.Num2 = 1)
Dim Salir As Boolean = False
Dim NCAjuste As Integer = -1
Dim NCGarantiaTotal As Integer = -1
If ArrayNC.Length > 2 Then
NCAjuste = ArrayNC(1).ToEntero()
NCGarantiaTotal = ArrayNC(2).ToEntero()
End If
Using ObjAcum As New ClsAcumuladores
If ObjAcum.GetGarantiasDetalle(RNC.CveVenta) Then
'SI ES GARANTIA TOTAL
If ObjAcum.DtResultados.MAX("PorcentajeAjuste") = "1" Then
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=443174, AplicaParaVenta:=1).Rows(0)
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCGarantiaTotal, AplicaParaVenta:=1).Rows(0)
Salir = True
Else
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=443173, AplicaParaVenta:=1).Rows(0)
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=NCAjuste, AplicaParaVenta:=1).Rows(0)
End If
End If
End Using
@@ -27499,7 +27807,7 @@ Partial Class Ventas
#End Region
Protected Sub BtnModalAplicarRemisionesNC_Click(sender As Object, e As EventArgs)
CargaRNC()
ChkMostarProductosRNC_CheckedChanged(ChkMostarProductosRNC, EventArgs.Empty)
RegistraScript("$('#ModalAplicarRemisionesNC').modal({backdrop: 'static', keyboard: false });")
End Sub
@@ -28096,4 +28404,5 @@ Partial Class Ventas
Public ImporteBonificacion As Decimal = 0
Public IVABonificacion As Decimal = 0
End Class
End Class