Correciones en autorizaciones

This commit is contained in:
2022-01-12 15:21:24 -07:00
parent b700371095
commit 13119a2575
2 changed files with 325 additions and 156 deletions

View File

@@ -3341,7 +3341,7 @@
</div>
<div class="col-md-6">
<asp:DropDownList ID="DdlCuentaEfectivo" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" AutoPostBack="true" DataTextField="NumCuentaMoneda" DataValueField="CveCuenta" Width="100%"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVCuenta" runat="server" ControlToValidate="DdlCuentaEfectivo" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="RFVCuenta" runat="server" ClientValidationFunction="ValidaCuentaEfectivo" ControlToValidate="DdlCuentaEfectivo" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:CustomValidator>
<ajax:ValidatorCalloutExtender ID="VCOCuenta" runat="server" HighlightCssClass="vco" TargetControlID="RFVCuenta" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
@@ -3349,7 +3349,7 @@
<div class="chequesie1">
<div class="row">
<label class="col-md-2">Credito:</label>
<label class="col-md-2">Crédito:</label>
<div class="col-md-4 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtImporteCredito" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
@@ -3357,7 +3357,7 @@
</div>
<div class="col-md-6" runat="server" id="DivDdlCuentaTarjetaCredito" style="margin-right: -40px">
<asp:DropDownList ID="DdlCuentaTarjetaCredito" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" AutoPostBack="true" DataTextField="NumCuentaMoneda" DataValueField="CveCuenta" Width="100%"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DdlCuentaTarjetaCredito" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="RequiredFieldValidator1" runat="server" ClientValidationFunction="ValidaCuentaCredito" ControlToValidate="DdlCuentaTarjetaCredito" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:CustomValidator>
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" runat="server" HighlightCssClass="vco" TargetControlID="RequiredFieldValidator1" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-3" runat="server" id="DivMesesSinIntereses" visible="false" style="text-align: right;">
@@ -3377,7 +3377,7 @@
<div class="chequesie1">
<div class="row">
<label class="col-md-2">Debito:</label>
<label class="col-md-2">Débito:</label>
<div class="col-md-4 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtImporteDebito" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
@@ -3385,7 +3385,7 @@
</div>
<div class="col-md-6">
<asp:DropDownList ID="DdlCuentaTarjetaDebito" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" AutoPostBack="true" DataTextField="NumCuentaMoneda" DataValueField="CveCuenta" Width="100%"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="DdlCuentaTarjetaDebito" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="RequiredFieldValidator4" runat="server" ClientValidationFunction="ValidaCuentaDebito" ControlToValidate="DdlCuentaTarjetaDebito" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:CustomValidator>
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender9" runat="server" HighlightCssClass="vco" TargetControlID="RequiredFieldValidator4" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
@@ -3400,7 +3400,7 @@
</div>
<div class="col-md-6">
<asp:DropDownList ID="DdlCuentaCheque" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" AutoPostBack="true" DataTextField="NumCuentaMoneda" DataValueField="CveCuenta" Width="100%"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="DdlCuentaCheque" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="RequiredFieldValidator3" runat="server" ClientValidationFunction="ValidaCuentaCheque" ControlToValidate="DdlCuentaCheque" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:CustomValidator>
<ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender11" runat="server" HighlightCssClass="vco" TargetControlID="RequiredFieldValidator3" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
@@ -3416,7 +3416,7 @@
</div>
<div class="col-md-6">
<asp:DropDownList ID="DdlCuentaTransferencia" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" AutoPostBack="true" DataTextField="NumCuentaMoneda" DataValueField="CveCuenta" Width="100%"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVTransferencia" runat="server" ControlToValidate="DdlCuentaTransferencia" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="RFVTransferencia" runat="server" ClientValidationFunction="ValidaCuentaTransferencia" ControlToValidate="DdlCuentaTransferencia" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Cuenta''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpAgregarPago"></asp:CustomValidator>
<ajax:ValidatorCalloutExtender ID="VCETransferencia" runat="server" HighlightCssClass="vco" TargetControlID="RFVTransferencia" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
@@ -3480,6 +3480,8 @@
</div>
<div class="row">
<div class="col-md-6">
<asp:HiddenField ID="HdnCambioFaltante" runat="server" Value="1" ClientIDMode="Static" />
<%--<asp:HiddenField ID="HdnPagadoContado" runat="server" Value="0" ClientIDMode="Static" />--%>
</div>
<label id="lblCambio" class="col-md-2">Cambio:</label>
<div class="col-md-4 input-icon">
@@ -7749,6 +7751,7 @@
<asp:ListItem Value="1" Text="Importe"></asp:ListItem>
<asp:ListItem Value="2" Text="Vencimiento"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVTipoAut" runat="server" CssClass="help-block errorimput" InitialValue="-1" ControlToValidate="DdlTipoAutorizacion" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Tipo''</b> es necesario, por favor ingréselo." ValidationGroup="VgmGuardarAut"></asp:RequiredFieldValidator>
<label for="<%= DdlTipoAutorizacion.ClientID.ToString()%>">Tipo Autorización:</label>
</div>
<div id="DivDiasVencidos" runat="server" visible="false" class="row">
@@ -7836,6 +7839,61 @@
$("#BtnDirClienteValidar").click();
}
function ValidaCuentaEfectivo(val, args) {
//VALIDA SOLO SI EL IMPORTE ES MAYOR A CERO
var totalPago = ToDouble($get("TxtImporteEfectivo").value);
if (totalPago > 0) {
args.IsValid = (ToDouble(args.Value) > 0);
}else
{
args.IsValid = true;
}
}
function ValidaCuentaCredito(val, args) {
//VALIDA SOLO SI EL IMPORTE ES MAYOR A CERO
var totalPago = ToDouble($get("TxtImporteCredito").value);
if (totalPago > 0) {
args.IsValid = (ToDouble(args.Value) > 0);
}else
{
args.IsValid = true;
}
}
function ValidaCuentaDebito(val, args) {
//VALIDA SOLO SI EL IMPORTE ES MAYOR A CERO
var totalPago = ToDouble($get("TxtImporteDebito").value);
if (totalPago > 0) {
args.IsValid = (ToDouble(args.Value) > 0);
}else
{
args.IsValid = true;
}
}
function ValidaCuentaCheque(val, args) {
//VALIDA SOLO SI EL IMPORTE ES MAYOR A CERO
var totalPago = ToDouble($get("TxtImporteCheque").value);
if (totalPago > 0) {
args.IsValid = (ToDouble(args.Value) > 0);
}else
{
args.IsValid = true;
}
}
function ValidaCuentaTransferencia(val, args) {
//VALIDA SOLO SI EL IMPORTE ES MAYOR A CERO
var totalPago = ToDouble($get("TxtImporteTransferencia").value);
if (totalPago > 0) {
args.IsValid = (ToDouble(args.Value) > 0);
}else
{
args.IsValid = true;
}
}
//FUNCIONES PARA COMERCIO EXTERIOR
function CalculaTotalUSD(TotalUSD, ValorUnitario, TxtCantidad) {
TotalUSD.innerText = FormatoNumero(ToDouble(ValorUnitario.value) * ToDouble(TxtCantidad.value), 2);
@@ -8868,14 +8926,16 @@
} catch (e) { }
var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC + totalAmortizado + totalProntoPago;
var totalVenta = ToDouble($get('TxtTotal').value);
var totalVenta = ToDouble($get('TxtTotal').value);// - ToDouble($get('HdnPagadoContado').value);
if (total > totalVenta) {
lblCambio.innerHTML = "Cambio:"
lblCambio.innerHTML = "Cambio:";
HdnCambioFaltante.value = "1";
$get("TxtCambio").value = FormatoNumero(total - totalVenta);
} else {
if ('<%= UsuarioActual.Empresa.Funcionalidad(531) %>' == '1') {
lblCambio.innerHTML = "Faltante:"
lblCambio.innerHTML = "Faltante:";
HdnCambioFaltante.value = "2";
$get("TxtCambio").value = FormatoNumero(total - totalVenta, 2);
} else {
$get("TxtCambio").value = "$0.00"

View File

@@ -1869,6 +1869,24 @@ Partial Class Ventas
ViewState("CveEstatusCotizacion") = value
End Set
End Property
Private Property CveMetodoPago33Venta As Integer
Get
Return (IfNull(ViewState("CveMetodoPago33Venta"), "-1", ViewState("CveMetodoPago33Venta"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveMetodoPago33Venta") = value
End Set
End Property
Private Property CveFormaPago33Venta As Integer
Get
Return (IfNull(ViewState("CveFormaPago33Venta"), "-1", ViewState("CveFormaPago33Venta"))).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveFormaPago33Venta") = value
End Set
End Property
Private Property DiasCredito As Integer
Get
Return ViewState("DiasCredito").ToString().ToEntero()
@@ -4551,6 +4569,9 @@ Partial Class Ventas
DdlMetodoPago33.SelectedValueExist(DbRowVenta("CveMetodoPago33").ToString())
DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero())
Me.CveMetodoPago33Venta = DbRowVenta("CveMetodoPago33").ToString().ToEntero()
Me.CveFormaPago33Venta = DbRowVenta("CveFormaPago33").ToString().ToEntero()
If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString() And DbRowVenta("CveFormaPago33").ToString() <> "" Then
'sino está seleccionada la asginada la debe de cargar
Dim Nombre As String = GlobalDTVtaFormaPago().FiltroPrimeroValor("FormaPagoSAT", String.Format("CveFormaPago={0}", DbRowVenta("CveFormaPago33")))
@@ -6382,8 +6403,10 @@ Partial Class Ventas
If Not EsCreaApartirDe AndAlso (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then
DdlTipoComprobante.SelectedValueExist("Cot")
Else
DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
DdlTipoComprobante.SelectedValue = "PA"
If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
DdlTipoComprobante.SelectedValueExistInsert("PA", "Autorización")
DdlTipoComprobante.SelectedValue = "PA"
End If
End If
TxtFechaPago.Text = Now.AddDays(PlazoCobranza).ToShortDateString
@@ -6391,14 +6414,17 @@ Partial Class Ventas
If IfNull(Request("Op"), "").ToString() = "Cot" OrElse (DdlTipoComprobante.SelectedValue = "Cot" AndAlso CveVenta > 0) Then DdlTipoComprobante.SelectedValue = "Cot"
'quito remisión y factura
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
If Not UsuarioActual.TienePermisoProceso(325) Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
If UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ing"))
If Not UsuarioActual.TienePermisoProceso(325) Then
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
End If
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
End If
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Rem"))
'SI ES AUTORIZACION DEBE PERMITIR GENERARLA
If (Not DdlTipoComprobante.SelectedValue.Contiene("PA")) Then
If (Not DdlTipoComprobante.SelectedValue.Contiene("PA")) AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
BtnEmitirImprimir.Visible = False
BtnsFacturar.Visible = False
LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274)
@@ -6434,7 +6460,7 @@ Partial Class Ventas
'GENERAR AUTORIZACION SI TIENE EXCEDIO EL LIMITE DE CREDITO
Select Case ValorAutorizacion
Case "1" 'CREAR DOCUMENTO DE AUTORIZACION PA
If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") AndAlso Not (UsuarioActual.Empresa.Funcionalidad(702).Contiene("2")) Then
If Not UsuarioActual.TienePermisoProceso(268) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing", "Ant", "PA") AndAlso Not (UsuarioActual.Empresa.Funcionalidad(702).Contiene("2")) AndAlso UsuarioActual.Empresa.Funcionalidad(531) <> "1" Then
'VERIFICAR CANDADOS DE VENTA, REMISIONES SIN FACTURAR, FACTURAS QUE NO TENGAN VENCIDAS
Dim Vta As New ClsVentas
@@ -7830,8 +7856,91 @@ Partial Class Ventas
ObjContrato.Dispose()
End If
Me.CveAutorizacion = -1
'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") AndAlso RBLPago.SelectedValue = "1" Then
Dim TipoDocumentoAutorizacion As String = ""
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim DiasVencidosAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
Try
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
If TieneDiasVencidos Then
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion IN(1,2) AND CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'", Orderby:="Importe DESC")
Else
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'", Orderby:="Importe DESC")
End If
If RowAutorizacion IsNot Nothing Then
TipoDocumentoAutorizacion = RowAutorizacion("CveTipoDocumento").ToString()
ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
DiasVencidosAutorizacion = RowAutorizacion("DiasVencidos").ToString().ToEntero()
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al obtener las autorizaciones", ex)
End Try
ObjVentas.Dispose()
If TipoDocumentoAutorizacion = "Ing" Then
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
CveAutorizacion = -1
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
'If TipoAutorizacion = 2 Then
' If DiasVencidosCliente > DiasVencidosAutorizacion Then
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. Los días vencidos del cliente son mayores a lo autorizado", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
'End If
'SI NO SE ENCONTRO NINGUA AUTORIZACION
If TipoAutorizacion = 0 Then
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TipoDocumentoAutorizacion = "Egs" Then
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
CveAutorizacion = -1
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
End If
'No exceder el limite de credito, Si no tiene contrato limita el credito, si tiene no hace nada. Si no tiene remisiones tampoco hace nada.
If (Not CveContrato > 0 Or CveContratoTipo.Contiene(28)) AndAlso (Not NuevaFactura = 1) AndAlso RBLPago.SelectedValue = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso RemisionesLista.Count <= 0 AndAlso TxtTotal.Text.ToDecimal > 0 AndAlso Not CvePedidoA > 0 Then
If Me.CveAutorizacion <= 0 AndAlso (Not CveContrato > 0 Or CveContratoTipo.Contiene(28)) AndAlso (Not NuevaFactura = 1) AndAlso RBLPago.SelectedValue = "1" AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso RemisionesLista.Count <= 0 AndAlso TxtTotal.Text.ToDecimal > 0 AndAlso Not CvePedidoA > 0 Then
'If UsuarioActual.Empresa.Funcionalidad(518) = "1" AndAlso Not UsuarioActual.TienePermisoProceso(185) Then
If Not UsuarioActual.Empresa.Funcionalidad(702) = "1" Then
@@ -8085,90 +8194,6 @@ Partial Class Ventas
Exit Sub
End If
Me.CveAutorizacion = -1
'SI ES A CREDITO DEBE VERIFICAR SI TIENE AUTORIZACIONES
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CveCliente > 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs") AndAlso RBLPago.SelectedValue = "1" Then
Dim TipoDocumentoAutorizacion As String = ""
Dim ImporteAutorizacion As Decimal = 0
Dim TipoAutorizacion As Integer = 0
Dim DiasVencidosAutorizacion As Integer = 0
Dim CveVendedor As Integer = DdlVendedor.SelectedValue.ToEntero()
Dim ObjVentas As New ClsVentas
Try
If ObjVentas.GetAutorizacionLimite(UsuarioActual.CveEmpresa, CveCliente, CveVendedor, CveEstatus:=1) Then
Dim RowAutorizacion As DataRow = Nothing
'SI TIENE DIAS VENCIDOS BUSCAR POR TIPO VENCIMIENTO
If TieneDiasVencidos Then
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 2 AND CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'")
Else
RowAutorizacion = ObjVentas.DtResultados.FiltroPrimero($"TipoAutorizacion = 1 AND CveVenta IS NULL AND CveTipoDocumento='{DdlTipoComprobante.SelectedValue}'", Orderby:="Importe DESC")
End If
If RowAutorizacion IsNot Nothing Then
TipoDocumentoAutorizacion = RowAutorizacion("CveTipoDocumento").ToString()
ImporteAutorizacion = RowAutorizacion("Importe").ToString().ToDecimal()
CveAutorizacion = RowAutorizacion("CveAutorizacion").ToString().ToEntero()
TipoAutorizacion = RowAutorizacion("TipoAutorizacion").ToString().ToEntero()
DiasVencidosAutorizacion = RowAutorizacion("DiasVencidos").ToString().ToEntero()
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al obtener las autorizaciones", ex)
End Try
ObjVentas.Dispose()
If TipoDocumentoAutorizacion = "Ing" Then
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
CveAutorizacion = -1
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
'If TipoAutorizacion = 2 Then
' If DiasVencidosCliente > DiasVencidosAutorizacion Then
' CveAutorizacion = -1
' Alert($"El crédito no esta autorizado. Los días vencidos del cliente son mayores a lo autorizado", TipoMensaje.MsgAdvertencia)
' Exit Sub
' End If
'End If
'SI NO SE ENCONTRO NINGUA AUTORIZACION
If TipoAutorizacion = 0 Then
If TieneDiasVencidos Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
If TieneDiasVencidos AndAlso DdlTipoComprobante.SelectedValue = "Egs" AndAlso CveAutorizacion <= 0 Then
CveAutorizacion = -1
Alert($"El crédito no esta autorizado. No tiene autorización para generar notas de crédito. El cliente tiene días vencidos", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TipoDocumentoAutorizacion = "Egs" Then
If TipoAutorizacion = 1 Then
If ImporteAutorizacion < TxtTotal.Text.ToDecimal() Then
CveAutorizacion = -1
Alert($"El crédito autorizado es insuficiente. Crédito Disponible:{ImporteAutorizacion:N2}", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
End If
End If
EmitirImprimirNew(TipoDoctoViejo)
End Sub
@@ -11606,7 +11631,7 @@ Partial Class Ventas
factura.Timbre.Comprobante.Serie = ObjVentas.Serie
factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString()
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso factura.TipoDocto = "Ing" AndAlso Me.CveAutorizacion > 0 Then
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveAutorizacion > 0 Then
If Not ObjVentas.UpdateAutorizacionLimite(Me.CveAutorizacion, factura.CveCliente, factura.CveVenta) Then
ErrorList.Add("Error al guardar los limites de la autorizacion")
End If
@@ -17068,8 +17093,9 @@ Partial Class Ventas
Private Function CalcularDescuentos(CvePS As Integer, Cantidad As Decimal, PU As Decimal) As Descuentos
Dim Descuento As Decimal = HdnDescuento.Value.ToDecimal
If UsuarioActual.Empresa.Funcionalidad(572) = "1" AndAlso UsuarioActual.TienePermisoProceso(328) AndAlso Not TbDescuentosRNC.Visible Then
If UsuarioActual.Empresa.Funcionalidad(572) = "1" AndAlso Not TbDescuentosRNC.Visible Then
TbDescuentosRNC.Visible = True
LnkDescuentosRNC.Visible = UsuarioActual.TienePermisoProceso(328)
End If
If HdnTipoDescuento.Value = "0" Then
@@ -20504,7 +20530,7 @@ Partial Class Ventas
ImgDescTotal.Attributes.Add("onclick", "javascript:$('#ModalDescuento').modal(); $get('LblTitulo1').style.display = ''; $get('LblTitulo2').style.display = 'none'; $get('LblTituloTipo1').style.display = ''; $get('LblTituloTipo2').style.display = 'none'; $get('HdnTipoDescuento').value = '2'; $get('LblPrecio1').style.display = 'none'; $get('LblTotalPS1').style.display = 'none'; $get('LblSubTotal1').style.display = ''; $get('LblAmort').style.display = 'none'; $get('BtnAplicarDescP').style.display = 'none'; $get('BtnAplicarDescG').style.display = ''; $get('TrMotivoDescuento').style.display = '';")
LblSubTotal1.Text = TxtSubTotal.Text
LblAmort.Text = TxtSubTotal.Text
LimpiaEscondeContado()
UpPS.Update()
UpCliente.Update()
UPObservaciones.Update()
@@ -20992,8 +21018,18 @@ Partial Class Ventas
DdlMetodoPago33.SelectedValueExist("3")
DdlMetodoPago33.Enabled = False
If Me.CveVenta > 0 AndAlso (Not Me.EsCreaApartirDe) AndAlso (Not Me.ModalidadEdicion) AndAlso Me.CveMetodoPago33Venta > 0 Then
DdlMetodoPago33.SelectedValueExist(Me.CveMetodoPago33Venta)
End If
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
If Me.CveVenta > 0 AndAlso (Not Me.EsCreaApartirDe) AndAlso Me.CveFormaPago33Venta > 0 Then
DdlFormaPago33.SelectedValueExist(Me.CveFormaPago33Venta)
End If
If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
DdlFormaPago33.Enabled = False
DdlFormaPago33.SelectedValueExist("20")
End If
@@ -21016,7 +21052,11 @@ Partial Class Ventas
If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then
DdlFormaPago33.Enabled = True
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
End If
CargaFormaPago(DdlMetodoPago33.SelectedValue.ToEntero())
If Me.CveVenta > 0 AndAlso (Not Me.EsCreaApartirDe) AndAlso (Not Me.ModalidadEdicion) AndAlso Me.CveFormaPago33Venta > 0 Then
DdlFormaPago33.SelectedValueExist(Me.CveFormaPago33Venta)
End If
End If
@@ -21073,10 +21113,15 @@ Partial Class Ventas
DtCC.Dispose()
DdlCuentaEfectivo.DataBind()
'DdlCuentaEfectivo.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlCuentaTarjetaCredito.DataBind()
'DdlCuentaTarjetaCredito.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlCuentaTarjetaDebito.DataBind()
'DdlCuentaTarjetaDebito.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlCuentaCheque.DataBind()
'DdlCuentaCheque.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlCuentaTransferencia.DataBind()
'DdlCuentaTransferencia.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
@@ -21126,6 +21171,11 @@ Partial Class Ventas
Return Folio
End Function
Private Sub CargaGridContado()
'If DtPagos IsNot Nothing Then
' HdnPagadoContado.Value = DtPagos.SUMD("Importe").ToString()
'Else
' HdnPagadoContado.Value = "0"
'End If
GvPagos.DataSource = DtPagos
GvPagos.DataBind()
End Sub
@@ -21148,6 +21198,12 @@ Partial Class Ventas
DtPagos = New DataTable
Dim Cambio As Decimal = TxtCambio.Text.ToDecimal
'SI ES FALTANTE NO DEBE CONSIDERARSE
If HdnCambioFaltante.Value = "2" Then
Cambio = 0
End If
DtPagos.Columns.Add("CveTipoMovimiento", GetType(String))
DtPagos.Columns.Add("TipoMovimiento", GetType(String))
DtPagos.Columns.Add("CveCuenta", GetType(String))
@@ -21161,13 +21217,15 @@ Partial Class Ventas
If total <= 0 Then Alert("No se ha ingresado importe", TipoMensaje.MsgAdvertencia) : Exit Sub
If TxtCambio.Text.ToDecimal > 0 And TxtImporteEfectivo.Text.ToDecimal < TxtCambio.Text.ToDecimal Then
If Cambio > 0 And TxtImporteEfectivo.Text.ToDecimal < Cambio Then
Alert("Debe haber un pago en efectivo y ser mayor que el cambio. Si no, ser pago exacto.", TipoMensaje.MsgAdvertencia)
CargaGridContado()
Exit Sub
End If
If (DtPagos.SUM("Importe").ToString().ToDecimal + total - TxtCambio.Text.ToDecimal) > TxtTotal.Text.ToDecimal Then
If (DtPagos.SUM("Importe").ToString().ToDecimal + total - Cambio) > TxtTotal.Text.ToDecimal Then
Alert("El importe de los pagos no puede exceder el importe de la factura. Por favor rectifique.", TipoMensaje.MsgAdvertencia)
CargaGridContado()
Exit Sub
End If
@@ -21179,7 +21237,7 @@ Partial Class Ventas
DrEfectivo("TipoMovimiento") = "Pago en Efectivo"
DrEfectivo("CveCuenta") = DdlCuentaEfectivo.SelectedValue
DrEfectivo("Cuenta") = DdlCuentaEfectivo.SelectedItem.Text
DrEfectivo("Importe") = TxtImporteEfectivo.Text.ToDecimal - TxtCambio.Text.ToDecimal
DrEfectivo("Importe") = TxtImporteEfectivo.Text.ToDecimal - Cambio
DrEfectivo("Folio") = CargaFolioContado(DdlCuentaEfectivo.SelectedValue.ToEntero(), 6)
DrEfectivo("Observaciones") = ""
DrEfectivo("Tipo") = "Caja Chica"
@@ -21422,6 +21480,53 @@ Partial Class Ventas
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso RBLPago.SelectedValue = "2" AndAlso CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant") Then
If Not TienePagos AndAlso TxtTotal.Text.ToDecimal > 0 Then
If MostrarAlertas Then
Alert("Es necesario especificar un pago.", TipoMensaje.MsgAdvertencia)
End If
Retorno = True
Return Retorno
End If
If TienePagos Then
Dim TotalPagoContado As Decimal = If(DtPagos IsNot Nothing, DtPagos.SUM("Importe").ToDecimal(), 0) + AmortizacionNC
Dim TotalProntoPago As Decimal = LblProntoPago.Text.ToDecimal()
If UsuarioActual.Empresa.Funcionalidad(572) = "1" Then
Dim TotalRNC As Decimal = If((ListaNCDesc IsNot Nothing AndAlso ListaNCDesc.Count > 0) OrElse (ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0), LblDescuentosRNC.Text.Trim().ToDecimal(), 0)
Dim ImporteTotal As Decimal = (TxtTotal.Text.ToDecimal).RoundSQL(2)
Dim TotalPagado = (TotalPagoContado + TotalRNC + TotalProntoPago).RoundSQL(2)
If TotalPagado <> ImporteTotal Then
If MostrarAlertas Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
End If
Retorno = True
Return Retorno
End If
Else
Dim TotalPagado = (TotalPagoContado + TotalProntoPago).RoundSQL(2)
If TotalPagado <> TxtTotal.Text.ToDecimal.RoundSQL(2) Then
If MostrarAlertas Then
Alert("La suma de los pagos debe ser igual al total de la venta.", TipoMensaje.MsgAdvertencia)
End If
Retorno = True
Return Retorno
End If
End If
End If
End If
'SI TIENE SALDO PENDIENTE VALIDA SI TIENE PAGOS
If Me.SaldoVenta > 0 Then
If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Rem", "Ant") AndAlso (UsuarioActual.Empresa.Funcionalidad(531) = "1") AndAlso (Not PermiteCredito) AndAlso Not TienePagos And TxtTotal.Text.ToDecimal > 0 Then
@@ -21952,10 +22057,10 @@ Partial Class Ventas
Dim DtDireccionEnvio As DataTable = Nothing
Dim ObjClientes As New ClsClientes
If ObjClientes.DireccionEnvioGet(DdlDireccionEnvio.SelectedValue.ToEntero(), CveCliente, CveClienteSucursal) Then
DtDireccionEnvio = ObjClientes.DtResultados
End If
Dim ObjClientes As New ClsClientes
If ObjClientes.DireccionEnvioGet(DdlDireccionEnvio.SelectedValue.ToEntero(), CveCliente, CveClienteSucursal) Then
DtDireccionEnvio = ObjClientes.DtResultados
End If
ObjClientes.Dispose()
If DtDireccionEnvio IsNot Nothing And DtDireccionEnvio.Rows.Count > 0 Then
@@ -22000,7 +22105,7 @@ Partial Class Ventas
RegistraScript("$('#divAddDireccionEnvio').modal();")
End Sub
#Region "D I R E C C I O N E N V I O - C O M B O S"
#Region "D I R E C C I O N E N V I O - C O M B O S"
Protected Sub BtnDirClienteValidar_Click(sender As Object, e As EventArgs)
DirClientevalidaCodigoPostal()
End Sub
@@ -22014,27 +22119,27 @@ Partial Class Ventas
Private Sub CargaDirClientePais()
DdlDirClientePais.DataSource = GlobalDTGralPaises()
DdlDirClientePais.DataBind()
DdlDirClientePais.SelectedValueExist("151")
End Sub
Private Sub CargaDirClienteEstado()
DdlDirClienteEstado.Items.Clear()
If DdlDirClientePais.SelectedValue.ToEntero > 0 Then
DdlDirClienteEstado.DataSource = GlobalDTGralEstados("-1", DdlDirClientePais.SelectedValue.ToEntero)
End If
DdlDirClienteEstado.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteEstado.DataBind()
DdlDirClientePais.DataSource = GlobalDTGralPaises()
DdlDirClientePais.DataBind()
DdlDirClientePais.SelectedValueExist("151")
End Sub
Private Sub CargaDirClienteColonia()
DdlDirClienteColonia.Items.Clear()
Private Sub CargaDirClienteEstado()
DdlDirClienteEstado.Items.Clear()
If DdlDirClientePais.SelectedValue.ToEntero > 0 Then
DdlDirClienteEstado.DataSource = GlobalDTGralEstados("-1", DdlDirClientePais.SelectedValue.ToEntero)
End If
DdlDirClienteEstado.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteEstado.DataBind()
End Sub
Private Sub CargaDirClienteColonia()
DdlDirClienteColonia.Items.Clear()
If DdlDirClienteMunicipio.SelectedValue.ToEntero > 0 Then
DdlDirClienteColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlDirClienteMunicipio.SelectedValue.ToEntero, CodigoPostal:=If(TxtEnvioCP.Text.Trim.Length > 0, TxtEnvioCP.Text.ToEntero, -1))
End If
DdlDirClienteColonia.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteColonia.DataBind()
End If
DdlDirClienteColonia.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteColonia.DataBind()
End Sub
@@ -22051,24 +22156,24 @@ Partial Class Ventas
End Sub
Private Sub CargaDirClienteMunicipio()
DdlDirClienteMunicipio.Items.Clear()
If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then
DdlDirClienteMunicipio.DataSource = GlobalDTGralMunicipios("-1", DdlDirClienteEstado.SelectedValue.ToEntero)
End If
DdlDirClienteMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteMunicipio.DataBind()
DdlDirClienteMunicipio.Items.Clear()
If DdlDirClienteEstado.SelectedValue.ToEntero > 0 Then
DdlDirClienteMunicipio.DataSource = GlobalDTGralMunicipios("-1", DdlDirClienteEstado.SelectedValue.ToEntero)
End If
DdlDirClienteMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlDirClienteMunicipio.DataBind()
End Sub
Protected Sub DdlDirClientePais_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaDirClienteEstado()
CargaDirClienteMunicipio()
CargaDirClienteColonia()
CargaDirClienteLocalidad()
End Sub
Protected Sub DdlDirClienteEstado_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaDirClienteMunicipio()
CargaDirClienteColonia()
CargaDirClienteLocalidad()
Protected Sub DdlDirClientePais_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaDirClienteEstado()
CargaDirClienteMunicipio()
CargaDirClienteColonia()
CargaDirClienteLocalidad()
End Sub
Protected Sub DdlDirClienteEstado_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaDirClienteMunicipio()
CargaDirClienteColonia()
CargaDirClienteLocalidad()
End Sub
Protected Sub DdlDirClienteMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs)
@@ -25945,7 +26050,7 @@ Partial Class Ventas
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) Then
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
End If
ObjMovtos.Dispose()
@@ -26025,7 +26130,7 @@ Partial Class Ventas
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) Then
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
End If
ObjMovtos.Dispose()
@@ -26065,7 +26170,7 @@ Partial Class Ventas
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1) Then
Me.TmpDTRNCDetalle = ObjMovtos.DtResultados.Copy()
End If
ObjMovtos.Dispose()
@@ -26140,7 +26245,7 @@ Partial Class Ventas
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1) Then
Me.TmpDTRNCDetalle = ObjMovtos.DtResultados.Copy()
End If
ObjMovtos.Dispose()
@@ -26188,7 +26293,7 @@ Partial Class Ventas
'GvRemisionesNCBonDetalle.DataBind()
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1) Then
Me.TmpDTRNCDetalle = ObjMovtos.DtResultados.Copy()
End If
ObjMovtos.Dispose()
@@ -26234,7 +26339,7 @@ Partial Class Ventas
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetRemisionesNCCliente(CveCliente, True, CveMoneda:=-1) Then
Me.TmpDTRNCBonificacionDetalle = ObjMovtos.DtResultados.Copy()
End If
ObjMovtos.Dispose()
@@ -32756,7 +32861,7 @@ Partial Class Ventas
Dim DtNC As DataTable = Nothing
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveMoneda:=-1) Then
DtNC = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'RNC' AND TipoRNC = 3 AND CveVenta > 0 and Saldo > 0", "Moneda,Fecha,Folio")
End If
ObjMovtos.Dispose()
@@ -32928,6 +33033,10 @@ Partial Class Ventas
Dim CveEstatus As Integer = 0
Dim TipoDocto As String = DdlTipoDocto.SelectedValue
Dim CveTipoAutorizacion As Integer = DdlTipoAutorizacion.SelectedValue.ToEntero()
If CveTipoAutorizacion <= 0 Then
Alert("Debe seleccionar un tipo de autorización", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If CveTipoAutorizacion = 2 Then
DiasVencidos = TxtDiasVencidos.Text.ToEntero()