--GDiaz: Generacion de NC en cobro por caja

This commit is contained in:
2024-10-20 17:21:06 -07:00
parent 2bb1ba7d3e
commit 909036cb12
3 changed files with 845 additions and 53 deletions

View File

@@ -3505,6 +3505,39 @@ Namespace Modelos
Pago.Referencia = Concepto
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
If Not ErrorPrepoliza AndAlso ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.EsNCAmortizacion AndAlso ObjFactura.TipoDocto.Contiene("Egs") AndAlso ObjFactura.DtAnticiposAplicados IsNot Nothing Then
For Each row2 As DataRow In ObjFactura.DtAnticiposAplicados.Rows
If row2("CveConceptoContable").ToString().ToEntero() = 3 Then
CveIEAnticipo = row2("CveIE").ToString().ToEntero()
importeMovimiento = row2("Importe").ToString().ToDecimal() '- ((row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.ToDecimal / row2.DataKey("TotalAnticipo").ToDecimal) * row2.DataKey("IVAAnticipo").ToDecimal)
Dim ImporteAnticipo As Decimal = importeMovimiento
Dim CveMonedaAnticipo As Integer = row2("CveMoneda").ToString().ToEntero()
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
If ObjFactura.CveTipoAmortizacionAnticipo = 2 Then
Dim DescuentosAnticipos As Decimal = row2("Descuentos").ToString().ToDecimal
ImporteAnticipo = ImporteAnticipo / (row2("TotalAnticipo").ToString().ToDecimal - DescuentosAnticipos) * row2("SubTotalAnticipo").ToString().ToDecimal
ImporteAnticipo = ImporteAnticipo.RoundSQL(2)
End If
Dim Importe11MX As Decimal = ImporteAnticipo
CveSubProyectoContabilizar = CveSubProyectoVenta
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe11MX, Importe11MX, 11, Referencia, Concepto, CveVenta:=row2("CveVenta").ToString().ToEntero(), CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
Exit For
End If
End If
End If
Next
End If
Next
If ObjConta.ValidacionesPrePoliza(ObjFactura.CvePrePoliza, UsuarioActual, Opcion:=5) Then
@@ -3517,6 +3550,9 @@ Namespace Modelos
' Dim DtTest = ObjConta.DtResultados
'End If
End If
importeMovimiento = 0
importeMX = 0
End If
If ErrorPrepoliza Then
@@ -3667,30 +3703,31 @@ Namespace Modelos
' cuando es amortización de nota de crédito, y es la nc
' cuando es amortización por descuento, y es el ingreso
' cuando es amortización en cero
If (ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") OrElse
ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse
ObjFactura.CveTipoAmortizacionAnticipo = 3) Then
For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
If row2("CveConceptoContable").ToString().ToEntero = 11 Then
CveIEAnticipo = -1
importeMovimiento = row2("Importe").ToString().ToDecimal()
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
If (ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse ObjFactura.CveTipoAmortizacionAnticipo = 3) Then
If DtAnticipos IsNot Nothing Then
For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows
If row2("CveConceptoContable").ToString().ToEntero = 11 Then
CveIEAnticipo = -1
importeMovimiento = row2("Importe").ToString().ToDecimal()
If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}"
CveSubProyectoContabilizar = CveSubProyectoVenta
CveSubProyectoContabilizar = CveSubProyectoVenta
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, ConceptoContable, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta,
CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo,
ImporteME:=If(tipoCambio = 1, 0, importeMovimiento),
CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
Exit For
Else
ObjFactura.SeGuardoPrePoliza = True
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, ConceptoContable, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta,
CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo,
ImporteME:=If(tipoCambio = 1, 0, importeMovimiento),
CveSubProyecto:=CveSubProyectoContabilizar) Then
ErrorPrepoliza = True
Exit For
Else
ObjFactura.SeGuardoPrePoliza = True
End If
End If
End If
End If
Next
Next
End If
End If
End If
@@ -6697,7 +6734,7 @@ Namespace Modelos
If Not ObjVentas.UpdateEstatusOCRelacionada(ObjFactura.CveVenta, CveEstatusCancelacion, ObjFactura.CveEmpresa) Then
ErrorCancelar = True
MensajeError = "Ocurrió un error al cancelar la orden de servicio"
else
Else
End If
End If
End If
@@ -7601,6 +7638,7 @@ Namespace Modelos
Public Property DtDocumentosRelacionados As Data.DataTable
Public Property DtNCVinculadas As Data.DataTable
Public Property DtAnticipos As Data.DataTable
Public Property DtAnticiposAplicados As Data.DataTable
Public Property DtPromociones As Data.DataTable
Public Property DtImpuestosLocales As Data.DataTable
Public Property DtPagos As Data.DataTable

View File

@@ -411,6 +411,10 @@
<div class="col-md-1" style="text-align: right;">
<asp:LinkButton ID="LnkLiberar" runat="server" CssClass="btn btn-xs btn-success" Text="Liberar" OnClick="LnkLiberar_Click" />
</div>
<div class="col-md-1" style="text-align: right;">
<asp:LinkButton ID="ImgAntiPend" Visible="false" OnClick="ImgAntiPend_Click" runat="server" Text=" <i class='fa fa-money'></i> " AlternateText="Aplicación de anticipos" Style="cursor: pointer;" />
</div>
</div>
</div>
@@ -524,6 +528,24 @@
</div>
</div>
<div class="chequesie1" id="DivAnticipo" runat="server" visible="false">
<div class="row">
<div class="col-md-2">
<label>Anticipos.:</label>
</div>
<div class="col-md-4 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtAnticipos" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" Enabled="false" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FTEAnticipo" runat="server" TargetControlID="TxtAnticipos" FilterType="Custom, Numbers" ValidChars=".," />
</div>
<div class="col-md-6">
<label>
<asp:Literal ID="LtlTipoAnticipo" runat="server"></asp:Literal></label>
<asp:HiddenField ID="HdnTipoAmortizacion" runat="server" Value="" />
</div>
</div>
</div>
<div class="chequesie1" runat="server" id="DivContadoOtros" visible="false">
<div class="row">
@@ -563,21 +585,21 @@
<div class="chequesie2">
<div class="row">
<label class="col-md-2">Total:</label>
<label class="col-md-1">Total:</label>
<div class="col-md-3 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtImporteContado" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" ReadOnly="true" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="TxtImporteContado" FilterType="Custom, Numbers" ValidChars=".," />
</div>
<label id="lblCambio" class="col-md-2">Cambio:</label>
<label id="lblCambio" class="col-md-1">Cambio:</label>
<div class="col-md-3 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtCambio" CssClass="form-control input-sm " Enabled="false" runat="server" MaxLength="12" Width="100px" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
<ajax:FilteredTextBoxExtender ID="FTBECambio" runat="server" TargetControlID="TxtCambio" FilterType="Custom, Numbers" ValidChars=".," />
<br />
</div>
<label id="lblCambio2" class="col-md-2">Sob/falt:</label>
<label id="lblCambio2" class="col-md-1">Sob/falt:</label>
<div class="col-md-3 input-icon">
<i style="margin: 0px;">$</i>
<asp:TextBox ID="TxtFaltante" CssClass="form-control input-sm " runat="server" MaxLength="12" Width="100px" ClientIDMode="Static" Style="text-align: right;"></asp:TextBox>
@@ -1008,7 +1030,6 @@
<asp:UpdatePanel class="modal-dialog" runat="server" ID="UpModalPago" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content">
<div class="modal-header ">
<h4 class="modal-title">
@@ -1016,9 +1037,6 @@
</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="form-group col-md-12 form-md-line-input">
<asp:DropDownList ID="DdlTipoTransaccion" CssClass="form-control input-sm select2me" ClientIDMode="Static" runat="server" DataTextField="TipoTransaccion" DataValueField="CveTipoTransaccion" ValidationGroup="GrpGuardarPago" Width="100%">
@@ -1093,6 +1111,163 @@
</asp:UpdatePanel>
</div>
<div id="DivAnticipos" class="modal ADS fade" role="dialog">
<asp:UpdatePanel runat="server" ID="UpAnticipos" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header ">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">
<asp:Label runat="server">Anticipos/NC del Cliente:&nbsp;<asp:Literal ID="LtlCliente" runat="server"></asp:Literal></asp:Label>
</h4>
</div>
<div class="modal-body">
<div class="row" runat="server" id="divAmortizacionTipo" visible="false">
<div class="col-md-4">
Tipo Amortización:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlTipoAmortizacionAnticipo" runat="server" AutoPostBack="true" Width="250px" CssClass="select2me" CausesValidation="true" OnSelectedIndexChanged="DdlTipoAmortizacionAnticipo_SelectedIndexChanged">
<asp:ListItem Text="Seleccionar" Value="-1"></asp:ListItem>
<asp:ListItem Text="Amortización anticipo en descuento" Value="1"></asp:ListItem>
<asp:ListItem Text="Amortización anticipo con nota de crédito" Value="2"></asp:ListItem>
</asp:DropDownList>
</div>
<asp:RequiredFieldValidator ID="RfvDdlTipoAmortizacionAnticipo" runat="server" Display="None" ControlToValidate="DdlTipoAmortizacionAnticipo" InitialValue="-1" ErrorMessage="Debe Seleccionarse un tipo" ValidationGroup="VGAnticiposClientes"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="CEDdlTipoAmortizacionAnticipo" runat="server" HighlightCssClass="vco" TargetControlID="RfvDdlTipoAmortizacionAnticipo" Width="300px"></ajax:ValidatorCalloutExtender>
<div class="row" style="text-align: center;" runat="server" id="divAnticipoMsg" visible="false">
<asp:Label ID="Label2" runat="server" Text="Se aplicará descuento por el total de las amortizaciones en los productos" CssClass="alert alert-warning" Style="padding: 5px; margin-bottom: 5px; padding-right: 25px;"></asp:Label>
</div>
</div>
<div class="row" id="divAmortizacionTipoRelacion" runat="server" visible="false">
<div class="col-md-4">
Tipo Relación:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlTipoRelacionAnticipo" runat="server" Width="250px" CssClass="select2me">
<asp:ListItem Text="07 - CFDI por aplicación de anticipo" Value="7"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="row" id="DivConceptoNC" runat="server" visible="false">
<div class="col-md-4">
Concepto:
</div>
<div class="col-md-8">
<asp:DropDownList ID="DdlNCPSAnt" runat="server" DataTextField="PSCodigo" DataValueField="CvePS" Width="250px" CssClass="select2me"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVNCPSAnt" runat="server" InitialValue="-1" ControlToValidate="DdlNCPSAnt" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Concepto''</b> es necesario, por favor ingréselo." ValidationGroup="VGAnticiposClientes"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCERFVNCPSAnt" runat="server" HighlightCssClass="vco" TargetControlID="RFVNCPSAnt" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
</div>
<div class="row" id="DivFechaAnticipoCliente" runat="server" visible="false">
<b>
<label class="col-md-2">Fecha:</label></b>
<div class="col-md-4">
<div class="input-group input-sm input-small date date-picker " data-date-format="dd/mm/yyyy" style="width: 80% !important; padding: 0px;">
<asp:TextBox ID="TxtFechaAnticipoCliente" runat="server" ClientIDMode="Static" CssClass="form-control" CausesValidation="true" MaxLength="10" AutoPostBack="true" OnTextChanged="TxtFechaAnticipoCliente_TextChanged"></asp:TextBox>
<span class="input-group-btn ">
<asp:LinkButton ID="ImgFechaAnticipoCliente" class="btn default " Text="<i class='fa fa-calendar'></i>" runat="server"></asp:LinkButton>
</span>
<ajax:MaskedEditExtender ID="MEEFechaAnticipoCliente" runat="server" TargetControlID="TxtFechaAnticipoCliente" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CEFechaAnticipoCliente" TargetControlID="TxtFechaAnticipoCliente" PopupButtonID="ImgFechaAnticipoCliente" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
<asp:CompareValidator ID="CvFechaAnticipoCliente" runat="server" ControlToValidate="TxtFechaAnticipoCliente" Display="None" Operator="DataTypeCheck" Type="Date" ValidationGroup="VGAnticiposClientes" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Fecha''</b> no tiene el formato correcto, por favor intente de nuevo con el siguiente formato: (dd/mm/yyyy)."></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VcoFechaAnticipoCliente" runat="server" Enabled="True" HighlightCssClass="vco" TargetControlID="CvFechaAnticipoCliente" Width="300px"></ajax:ValidatorCalloutExtender>
</div>
</div>
</div>
<br />
<div style="max-height: 300px; overflow-y: auto;">
<div class="row" style="margin-left: 0px; text-align: right" align="left">
<div class="col-md-2">
<asp:LinkButton ID="LnkRecargaAnticipos" NavigateUrl="#" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-refresh'></i> Actualizar" runat="server" OnClick="LnkRecargaAnticipos_Click" />
</div>
<div style="margin-right: 15px">
<input type="text" id="TxtBusquedaAnticipos" class="form-control input-sm" onkeyup="<%= String.Format("FiltrarTabla('TxtBusquedaAnticipos','{0}')", GVAnticipos.ClientID) %>" style="display: inline-block; margin-right: -20px; width: 150px;" />
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusquedaAnticipos','{0}')", GVAnticipos.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div>
</div>
<br />
<asp:GridView ID="GVAnticipos" runat="server" AutoGenerateColumns="False" ClientIDMode="Static" EmptyDataText="No se encontraron Anticipos del Cliente"
ToolTip="Listado de Anticipos" CssClass="GVAnticipos table table-striped table-hover Widthall mysmallbtn" data-height="300" Style="text-align: center;" GridLines="None"
DataKeyNames="ISTotal,Saldo,CveIE,Folio,Tipo,CveVenta,CveConceptoContable,CveConceptoContableAmor, TotalAnticipo, SubTotalAnticipo, IVAAnticipo,IEPS, ImpuestosLocalesAnticipo, SubTotalAmortizacion, SubTotal, Original, IVA, RetIVA, RetISR, FolioFiscal, CveClasificacionNC, TipoCambio,TipoCambioPago,TipoCambioHoy, CveMoneda,Fecha,SaldoSubTotal,SaldoConImpuestos,RegresarImpuesto,DevolucionImportePagado,CveCliente,Descuentos">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="Chk" runat="server" />
<asp:LinkButton ID="LnkSolicitarActivarAnticipo" Visible="false" NavigateUrl="#" CssClass="btn btn-circle btn-sm blue" Text="<i class='fa fa-check'></i>" ToolTip="Solicitar activar anticipo" runat="server" OnClick="LnkSolicitarActivarAnticipo_Click" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Folio</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlFactura" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Fecha</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlFecha" runat="server" Text='<%# Eval("Fecha", "{0:d}") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Saldo</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlAnticipos" runat="server" Text='<%# Eval("Saldo", "{0:N2}") %>'></asp:Literal>&nbsp;
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<HeaderTemplate>Moneda Venta</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="MonedaVenta" runat="server"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Moneda</HeaderTemplate>
<ItemTemplate>
<asp:Literal ID="LtlAbreviatura" runat="server" Text='<%# Eval("Abreviatura") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false">
<HeaderTemplate>Atención A</HeaderTemplate>
<ItemTemplate>
<asp:Literal runat="server" Text='<%# Eval("AtencionA") %>'></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>Amort. Ant.</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="LblTotalAnticipos" runat="server" ClientIDMode="Static" Text="0.00" Visible="false"></asp:Label>
<asp:TextBox ID="TxtAnticipo" CssClass="CSGATxtAnticipo" runat="server" CausesValidation="true" MaxLength="12" Width="76px"></asp:TextBox>
<asp:CompareValidator ID="CVAmortAnti" runat="server" ControlToValidate="TxtAnticipo" Display="None" ErrorMessage="El campo <b>''Amortización de Anticipos''</b> no tiene el formato correcto, por favor corrija e intente de nuevo (Solo formato numérico)." Operator="DataTypeCheck" Type="Currency" ValidationGroup="VGAnticiposClientes"></asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="VCOAmortAnti" runat="server" HighlightCssClass="vco" TargetControlID="CVAmortAnti" Width="300px"></ajax:ValidatorCalloutExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="T.C." Visible="false">
<ItemTemplate>
<asp:TextBox ID="TxtTC" runat="server" Width="50px" Enabled="false"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="BtnAceptarAnticipos" runat="server" Text="Aceptar" class="btn btn-primary" ValidationGroup="VGAnticiposClientes" />
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
@@ -1101,21 +1276,124 @@
//function impresionDirecta(urlPDF) {
// printJS({ printable: urlPDF, type: 'pdf', showModal: true });
//}
function chkAnt(t, txt, importe, AmorContrato = 0) {
let totalAnt = 0;
let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
//si es con.nc,es.el.total
let Total = ToDouble($get("C_LtlSaldo").value);
let SaldoCompra = parseFloat(parseFloat($get("C_LtlSaldo").value).toFixed(2));
if (t.checked) {
if (SaldoCompra > 0) {
if (AmorContrato > 0) {
txt.value = AmorContrato.toFixed(2);
} else {
txt.value = importe.toFixed(2);
}
totalAnt = FnSumaValoresAnt();
if (totalAnt > SaldoCompra) {
txt.value = FormatoNumero(importe - (totalAnt - SaldoCompra), 2);
//$get('HdnVentaSaldo').value = 0.00;
alert("El Importe no debe de exceder a el saldo");
}
} else {
t.checked = false;
}
} else {
//$get('HdnVentaSaldo').value = parseFloat(SaldoCompra) + parseFloat(txt.value);
txt.value = "";
}
$("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
}
function FnCambiaAnt(chk, txt, saldo) {
let Total = ToDouble($get("C_LtlSaldo").value);// ToDouble($get('TxtSubTotal').value);
let TipoAnticipo = $('#<%= DdlTipoAmortizacionAnticipo.ClientID %>').val();
let importeTxt = parseFloat(txt.value.replace(/,/g, ''));
if (TipoAnticipo == '4') {
Total = ToDouble($get("C_LtlSaldo").value);
}
if (isNaN(importeTxt)) {
importeTxt = 0;
} 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();
}
function FnSumaValoresAnt() {
let totalPoints = 0;
let t = '';
$('input[name*=TxtAnticipo]').each(function () {
totalPoints += ToDouble($(this).val());
});
return Math.round(totalPoints * 100) / 100;
}
function impresionBase64(pdfBase64) {
printJS({ printable: pdfBase64, type: 'pdf', showModal: true, base64: true });
}
function CalculaTotalPagoContado() {
debugger;
var totalEfectivo = ToDouble($get("TxtImporteEfectivo").value);
var totalCredito = ToDouble($get("TxtImporteCredito").value);
var totalDebito = ToDouble($get("TxtImporteDebito").value);
var totalCheque = ToDouble($get("TxtImporteCheque").value);
var totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
var TotalOtrosContado = 0;
var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado;
var totalVenta = ToDouble($get('HdnTotal').value);// - ToDouble($get('HdnTotal').value);
function CalculaTotalPagoContado() {
let totalEfectivo = ToDouble($get("TxtImporteEfectivo").value);
let totalCredito = ToDouble($get("TxtImporteCredito").value);
let totalDebito = ToDouble($get("TxtImporteDebito").value);
let totalCheque = ToDouble($get("TxtImporteCheque").value);
let totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
let TotalOtrosContado = 0;
let total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado;
if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) {
var totalAnticipos = ToDouble($get("TxtAnticipos").value);
total = total + totalAnticipos;
}
let totalVenta = ToDouble($get('HdnTotal').value);// - ToDouble($get('HdnTotal').value);
if (total > totalVenta) {
lblCambio.innerHTML = "Cambio:";
@@ -1131,14 +1409,13 @@
}
function CalculaDiferencia() {
;
var total = 0
let total = 0;
total = ToDouble($('#C_TxtEfectivoEnCaja').val()) - ToDouble($('#C_LblEfectivoEsperado').text());
$('#C_LblDiferenciaCaja').text(FormatoNumero(total));
}
function CalculaDiferenciaBloqueo() {
var total = 0;
let total = 0;
total = ToDouble($('#C_TxtEfectivoCajaBloqueo').val()) - ToDouble($('#C_LblEfectivoBloqueo').text());
$('#C_LblDiferenciaCajaBloqueo').val(FormatoNumero(total));
}

View File

@@ -4,9 +4,19 @@ Option Strict On
Imports System.Data
Imports System.IO
Imports Extensiones
Imports Modelos.Factura
Partial Class Ventas_PVCobranza
Inherits ClsPaginas
Inherits ClsPaginas
Private Property TmpDTAnticiposNCIxCCliente As DataTable
Get
Return If(IsNothing(ViewState("TmpDTAnticiposNCIxCCliente")), Nothing, CType(ViewState("TmpDTAnticiposNCIxCCliente"), DataTable))
End Get
Set(value As DataTable)
ViewState("TmpDTAnticiposNCIxCCliente") = value
End Set
End Property
Private Property CveCorte As Integer
Get
@@ -76,6 +86,8 @@ Partial Class Ventas_PVCobranza
If UsuarioActual.CveEmpresa = 189 Then
DivDatosCheque.Visible = True
DivAnticipo.Visible = True
ImgAntiPend.Visible = True
End If
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
@@ -296,6 +308,7 @@ Partial Class Ventas_PVCobranza
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
LimpiarDatos()
If ChkMostrarSoloPagados.Checked Then
DVCobraza.Visible = False
@@ -343,6 +356,8 @@ Partial Class Ventas_PVCobranza
Private Sub GvDatos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvDatos.RowCommand
If e.CommandName = "Cobrar" Then
LimpiarDatos()
Dim ImgBtn As LinkButton = DirectCast(e.CommandSource, LinkButton)
Dim GvRow As GridViewRow = DirectCast(ImgBtn.BindingContainer, GridViewRow)
Dim TieneError As Boolean = False
@@ -404,7 +419,7 @@ Partial Class Ventas_PVCobranza
'registrar pago
'validaciones
Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal
Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal + TxtAnticipos.Text.ToDecimal()
If Pagado = 0 Then
Alert("Favor de especificar importe", TipoMensaje.ToastAdventencia)
Exit Sub
@@ -436,7 +451,8 @@ Partial Class Ventas_PVCobranza
End If
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero
Dim CveVentaRemision As Integer = -1
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
@@ -463,6 +479,7 @@ Partial Class Ventas_PVCobranza
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
VentaActual.UsuarioActual = UsuarioActual
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
If tCveCorte <= 0 AndAlso DbRowVenta("CveCorte").ToString.ToEntero > 0 Then tCveCorte = DbRowVenta("CveCorte").ToString.ToEntero
Dim CvePrePoliza As Integer
@@ -479,10 +496,14 @@ Partial Class Ventas_PVCobranza
Dim ObjClientes As New ClsClientes(ObjVentas2.IniciaTransacSQL())
Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing
Dim respNC As Modelos.Factura.MMensajeFactura = Nothing
Try
'FACTURAR LA REMISION PARA HACER EL PAGO
If UsuarioActual.CveEmpresa.Contiene(189, 197) AndAlso VentaActual.TipoDocto = "Rem" Then
CveVentaRemision = HdnCveVenta.Value.ToEntero
respFactura = GenerarFactura(VentaActual, ObjVentas2, ObjClientes)
If respFactura Is Nothing Then
@@ -496,6 +517,28 @@ Partial Class Ventas_PVCobranza
End If
End If
'GENERAR NC PARA AMORTIZACION
If MsgError = "" AndAlso UsuarioActual.CveEmpresa.Contiene(189) AndAlso HdnTipoAmortizacion.Value = "2" Then
respNC = GenerarNC(VentaActual, ObjVentas2)
If respNC IsNot Nothing Then
If respNC.TieneError Then
CveVenta = -1
If respNC.Mensajes.Count > 0 Then
MsgError = respNC.Mensajes(0)
Else
MsgError = "Ocurrió un error al generar la nota de crédito"
End If
Else
PagoAplicado += respNC.Factura.Total
SaldoPendiente = SaldoPendiente - PagoAplicado
End If
Else
MsgError = "Ocurrió un error al generar la nota de crédito"
End If
End If
If MsgError = "" Then
CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
@@ -546,14 +589,22 @@ Partial Class Ventas_PVCobranza
MsgError = "Tiene saldo pendiente por aplicar"
End If
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, tCveCorte) Then
MsgError = "Error al aplicar el corte"
If UsuarioActual.CveRol <> 1 Then
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, tCveCorte) Then
MsgError = "Error al aplicar el corte"
End If
End If
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaTicketImpreso(CveVenta, 0) Then
MsgError = "No se pudo desmarcar la impresión"
End If
If CveVentaRemision > 0 Then
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaTicketImpreso(CveVentaRemision, 0) Then
MsgError = "No se pudo desmarcar la impresión"
End If
End If
Else
MsgError = "Error al registrar prepólizas"
End If
@@ -578,6 +629,13 @@ Partial Class Ventas_PVCobranza
For Each m In respFactura.Mensajes
msBuild.AppendFormat("<br/> {0}", m)
Next
If respNC IsNot Nothing Then
For Each m In respNC.Mensajes
msBuild.AppendFormat("<br/> {0}", m)
Next
End If
Else
msBuild.Append($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1&REGENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>")
End If
@@ -599,8 +657,8 @@ Partial Class Ventas_PVCobranza
ImpresionDirectaPDF(CveVenta)
End If
PnlContado.Visible = False
HdnCveVenta.Value = ""
LimpiarDatos()
CargaDatos()
Catch ex As Exception
GuardaLog(ex.ToString())
@@ -612,6 +670,12 @@ Partial Class Ventas_PVCobranza
End Sub
Private Sub LimpiarDatos()
PnlContado.Visible = False
HdnCveVenta.Value = ""
HdnTipoAmortizacion.Value = ""
End Sub
Private Function GenerarFactura(ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes) As Modelos.Factura.MMensajeFactura
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
@@ -685,6 +749,7 @@ Partial Class Ventas_PVCobranza
ObjFactura.CalculaTotales()
ObjFactura.PreparaTimbre()
Dim SbAlert As New StringBuilder()
@@ -694,6 +759,7 @@ Partial Class Ventas_PVCobranza
Retorno.Factura = ObjFactura
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
For Each msg In Retorno.Mensajes
SbAlert.AppendFormat("{0} <br/>", msg)
Next
@@ -756,6 +822,97 @@ Partial Class Ventas_PVCobranza
Return Retorno
End Function
Private Function GenerarNC(ByRef Venta As Venta, ByRef ObjVentas As ClsVentas) As Modelos.Factura.MMensajeFactura
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
Dim ObjNC = Modelos.Factura.CrearVentaNueva(UsuarioActual, Venta.CveSubProyecto, Venta.CveCliente, Venta.CveMoneda, "Egs")
Dim Total As Decimal = TxtAnticipos.Text.ToDecimal()
Dim subTotal As Decimal = (Total / (1D + Venta.PorcentajeIVA))
'Dim IVA = (subTotal * Factura.PorcentajeIVA).RoundSQL(2)
Dim PU As Decimal = subTotal
Dim Cantidad As Decimal = 1D
Dim Descuento As Decimal = 0
Dim Obs = ""
ObjNC.AgregarPS(DdlNCPSAnt.SelectedValue.ToEntero(), Cantidad, PU, Descuento, Obs, CveSubProyecto:=Venta.CveSubProyecto, PorcentajeIVA:=Venta.PorcentajeIVA)
ObjNC.CalculaTotales()
Dim DtVentasNC = New DataTable
DtVentasNC.Columns.Add("CveVenta", GetType(Integer))
DtVentasNC.Columns.Add("Importe", GetType(Decimal))
DtVentasNC.Columns.Add("FolioFiscal", GetType(String))
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1})
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1})
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1})
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "Folio", .DataType = GetType(String), .DefaultValue = ""})
DtVentasNC.Rows.Add(Venta.CveVenta, Total, "")
ObjNC.DtVentasNC = DtVentasNC
Dim DtVentasRelacionadas As New DataTable()
DtVentasRelacionadas.Columns.Add("CveVenta", GetType(Integer))
DtVentasRelacionadas.Rows.Add(Venta.CveVenta)
ObjNC.DtVentasRelacionadas = DtVentasRelacionadas
Dim DtAnticipos As New DataTable()
DtAnticipos.Columns.Add("CveVenta", GetType(Integer))
DtAnticipos.Columns.Add("Importe", GetType(Decimal))
DtAnticipos.Columns.Add("CveConceptoContable", GetType(Integer))
DtAnticipos.Columns.Add("CveIE", GetType(Integer))
DtAnticipos.Columns.Add("FolioFiscal", GetType(String))
DtAnticipos.Columns.Add("Descuentos", GetType(Decimal))
DtAnticipos.Columns.Add("TotalAnticipo", GetType(Decimal))
DtAnticipos.Columns.Add("SubTotalAnticipo", GetType(Decimal))
DtAnticipos.Columns.Add("CveMoneda", GetType(Decimal))
For Each GvRow As GridViewRow In GVAnticipos.Rows
If GvRow.FCCheckBox("Chk" & GvRow.RowIndex) IsNot Nothing AndAlso GvRow.FCCheckBox("Chk" & GvRow.RowIndex).Checked Then
Dim CveVenta = GvRow.DataKey("CveVenta").ToEntero()
Dim Importe = GvRow.FCTextBox(String.Format("TxtAnticipo{0}", GvRow.RowIndex)).Text.ToDecimal()
Dim CveConceptoContable = GvRow.DataKey("CveConceptoContable").ToEntero()
Dim CveIE = GvRow.DataKey("CveIE").ToEntero()
Dim FolioFiscal = ""
Dim Descuentos As Decimal = GvRow.DataKey("Descuentos").ToDecimal()
Dim TotalAnticipo As Decimal = GvRow.DataKey("TotalAnticipo").ToDecimal()
Dim SubTotalAnticipo As Decimal = GvRow.DataKey("SubTotalAnticipo").ToDecimal()
Dim CveMoneda As Integer = GvRow.DataKey("CveMoneda").ToEntero()
DtAnticipos.Rows.Add(CveVenta, Importe, CveConceptoContable, CveIE, FolioFiscal, Descuentos, TotalAnticipo, SubTotalAnticipo, CveMoneda)
End If
Next
ObjNC.EsNCAmortizacion = True
ObjNC.CveTipoAmortizacionAnticipo = 2
ObjNC.DtAnticiposAplicados = DtAnticipos
ObjNC.PreparaTimbre()
Dim SbAlert As New StringBuilder()
Try
Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta")
Retorno.Factura = ObjNC
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
For Each msg In Retorno.Mensajes
SbAlert.AppendFormat("{0} <br/>", msg)
Next
SbAlert.AppendFormat("<ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Descargar PDF Factura</a></li></ul><br/>", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", Retorno.CveVenta)))
Else
SbAlert.Append("Ocurrió un error al generar la nota de crédito")
End If
Catch ex As Exception
SbAlert.Append("Ocurrió un error al generar el documento")
GuardaLog(ex.ToString())
End Try
Return Retorno
End Function
Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer, Optional Obs As String = "", Optional CveAutorizacion As String = "", Optional CveSubProyecto As Integer = -1) As String
Dim Retorno As String = ""
Dim CveIEPago As Integer = 0
@@ -1078,8 +1235,7 @@ Partial Class Ventas_PVCobranza
Dim ObjVentas As New ClsVentas
If ObjVentas.UpdateAsignaVentaCobranza(HdnCveVenta.Value.ToEntero, -1, -1, -1, "", Now) Then
PnlContado.Visible = False
HdnCveVenta.Value = ""
LimpiarDatos()
CargaDatos()
End If
ObjVentas.Dispose()
@@ -1132,9 +1288,7 @@ Partial Class Ventas_PVCobranza
End If
End Sub
Sub CargaDdlPagos()
Private Sub CargaDdlPagos()
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing' AND Estatus = 1")
DdlTipoTransaccion.DataBind()
@@ -1223,4 +1377,327 @@ Partial Class Ventas_PVCobranza
RegistraScript("$('#DVModalCobrosEnTranscurso').modal('show');")
End Sub
Protected Sub ImgAntiPend_Click(sender As Object, e As EventArgs)
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
'If DdlTipoAmortizacionAnticipo.Items.FindByValue("4") Is Nothing Then
' DdlTipoAmortizacionAnticipo.Items.Insert(1, New ListItem("Pago con devolución", "4"))
'End If
'DdlTipoAmortizacionAnticipo.SelectedValueExist("4")
DdlTipoRelacionAnticipo.SelectedValueExist("-1")
divAmortizacionTipoRelacion.Visible = False
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") IsNot Nothing Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
DdlTipoAmortizacionAnticipo_SelectedIndexChanged(DdlTipoAmortizacionAnticipo, EventArgs.Empty)
End If
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
End If
ObjVentas.Dispose()
If DbRowVenta IsNot Nothing Then
CargaAnticipos(DbRowVenta("CveCliente").ToString().ToEntero())
End If
UpAnticipos.Update()
RegistraScript("$('#DivAnticipos').modal();", "AE")
End Sub
Private Sub CargaAnticipos(CveCliente As Integer)
If CveCliente > 0 Then
'QUE NO SE PUEDA REALIZAR AMORTIZACIÓN DE ANTICIPO POR DESCUENTO
If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then
If DdlTipoAmortizacionAnticipo.Items.FindByValue("1") IsNot Nothing Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
End If
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then
Me.TmpDTAnticiposNCIxCCliente = ObjMovtos.DtResultados.Copy()
End If
'AGREGAR LOS ANTICIPOS, DEV, IxC QUE ESTEN EN PUBLICO GENERAL
If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing AndAlso UsuarioActual.CveEmpresa.Contiene(189, 190, 192, 195, 197) Then
Dim CveClientePublicoGeneral = UsuarioActual.Empresa.Funcionalidad(714).ToEntero()
If CveClientePublicoGeneral > 0 Then
If CveCliente <> CveClientePublicoGeneral Then
If ObjMovtos.GetAnticiposNCIxCCliente(CveClientePublicoGeneral) Then
For Each DrGeneral As DataRow In ObjMovtos.DtResultados.Rows
Me.TmpDTAnticiposNCIxCCliente.Rows.Add(DrGeneral.ItemArray)
Next
End If
End If
End If
End If
ObjMovtos.Dispose()
If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then
Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND Tipo IN('RNC','IxC','Ant') ")
GVAnticipos.DataSource = DtMovtos
If DtMovtos.Rows.Count > 0 Then ImgAntiPend.Visible = True
If UsuarioActual.Empresa.Funcionalidad(382) = "1" AndAlso DtMovtos IsNot Nothing AndAlso DtMovtos.Rows.Count = 0 Then
ImgAntiPend.Visible = False
End If
Else
GVAnticipos.DataSource = Nothing
End If
divAmortizacionTipo.Visible = True
If UsuarioActual.Empresa.Funcionalidad(343) = "1" Then
DdlTipoAmortizacionAnticipo.Items.Remove(DdlTipoAmortizacionAnticipo.Items.FindByValue("1"))
End If
GVAnticipos.Columns(4).Visible = False
GVAnticipos.Columns(8).Visible = False
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
GVAnticipos.Columns(6).Visible = True
End If
GVAnticipos.DataBind()
End If
UpAnticipos.Update()
End Sub
Protected Sub TxtFechaAnticipoCliente_TextChanged(sender As Object, e As EventArgs)
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
End If
ObjVentas.Dispose()
If DbRowVenta IsNot Nothing Then
CargaAnticipos(DbRowVenta("CveCliente").ToString().ToEntero())
End If
End Sub
Protected Sub LnkRecargaAnticipos_Click(sender As Object, e As EventArgs)
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
End If
ObjVentas.Dispose()
If DbRowVenta IsNot Nothing Then
CargaAnticipos(DbRowVenta("CveCliente").ToString().ToEntero())
End If
End Sub
Protected Sub LnkSolicitarActivarAnticipo_Click(sender As Object, e As EventArgs)
Dim CveCliente As Integer = -1
'falta sacar a los usuarios a notificar.
Dim gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).BindingContainer, GridViewRow)
Dim Folio As String = gvr.DataKey("Folio")
Dim dtt As DataTable = Nothing
Dim ObjProceso As New ClsSisProcesos
If ObjProceso.GetUsuariosconProceso(379, UsuarioActual.CveEmpresa) Then 'proceso para autorizar
dtt = ObjProceso.DtResultados.Copy()
End If
ObjProceso.Dispose()
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
For Each dr As DataRow In dtt.Rows
ClsSisNotificaciones.EnviarAlerta("Solicitud de Anticipo", $"Solicitud de activación de anticipo Folio: {Folio} <br/><a href='/Ventas/Clientes.aspx?CveCliente={CveCliente}&op=ant'>Ir Activar</a>", dr("CveUsuario").ToString, Tipo:=TipoNotificacion.ToastInformacionB)
Next
End If
UpAnticipos.Update()
End Sub
Protected Sub GVAnticipos_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowCreated
If e.Row.RowType = DataControlRowType.Header Then
e.Row.ClientIDMode = ClientIDMode.Static
e.Row.ID = String.Format("TrH{0}", e.Row.RowIndex)
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
e.Row.ClientIDMode = ClientIDMode.Static
e.Row.ID = String.Format("Tr{0}", e.Row.RowIndex)
e.Row.FCCheckBox("Chk").ID = "Chk" & e.Row.RowIndex
e.Row.FCTextBox("TxtAnticipo").ID = "TxtAnticipo" & e.Row.RowIndex
e.Row.FCTextBox("TxtTC").ID = "TxtTC" & e.Row.RowIndex
DirectCast(e.Row.FindControl("CVAmortAnti"), CompareValidator).ID = "CVAmortAnti" & e.Row.RowIndex
DirectCast(e.Row.FindControl("VCOAmortAnti"), AjaxControlToolkit.ValidatorCalloutExtender).ID = "VCOAmortAnti" & e.Row.RowIndex
DirectCast(e.Row.FindControl("CVAmortAnti"), CompareValidator).ControlToValidate = "TxtAnticipo" & e.Row.RowIndex
DirectCast(e.Row.FindControl("VCOAmortAnti"), AjaxControlToolkit.ValidatorCalloutExtender).TargetControlID = "CVAmortAnti" & e.Row.RowIndex
'SI NO TIENE PERMISO, NO PERMITIR APLICAR ANTICIPOS PUNTUALES
If GVAnticipos.DataSource IsNot Nothing Then
If CBool(e.Row.DBCampo("AnticipoPuntual")) AndAlso Not UsuarioActual.TienePermisoProceso(377) Then
e.Row.FCCheckBox("Chk").Enabled = False
End If
End If
End If
End Sub
Protected Sub GVAnticipos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal
If e.Row.RowIndex = 0 Then
e.Row.Cells(1).Width = Unit.Pixel(60)
e.Row.Cells(2).Width = Unit.Pixel(100)
e.Row.Cells(3).Width = Unit.Pixel(80)
e.Row.Cells(4).Width = Unit.Pixel(80)
End If
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right
If e.Row.DataKey("Saldo").ToDouble < 0 Then e.Row.Cells(3).ForeColor = Drawing.Color.Red
If e.Row.DataKey("Saldo").ToDouble = 0 Then e.Row.FCLiteral("LtlAnticipos").Text = ""
Dim saldo As Decimal = 0
Dim tipoCambio As Decimal = 0
Dim total As Decimal = LtlSaldo.Text.ToDecimal() '- Pagado
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("4") Then
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
Else
saldo = e.Row.DataKey("SaldoConImpuestos").ToString().ToDecimal
End If
e.Row.FCLiteral("LtlAnticipos").Text = saldo.FormatoNumero
saldo = saldo.RoundSQL()
Dim maxsaldo As Decimal = 0
If total > saldo Then
maxsaldo = saldo
Else
maxsaldo = total
End If
Dim AmortizacionSujeridaContrato As Decimal = 0
e.Row.FCLiteral("MonedaVenta").Text = saldo.FormatoNumero(2)
e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2});", e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).ClientID, saldo, AmortizacionSujeridaContrato))
e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1});", e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ClientID, saldo))
e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Attributes.Add("onKeyUp", String.Format("CambioTipoMoneda({0},{1},{2},{3},{4});", e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ClientID, e.Row.DataKey("Saldo"), e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).ClientID, e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).ClientID, e.Row.DataKey("CveMoneda")))
If e.Row.DataKey("CveIE").ToString().ToEntero() > 0 Then
e.Row.FCLiteral("LtlFactura").Text = String.Format("<a class=""Texto"" href=""/Bancos/IE.aspx?CveIE={0}"">{1}</a>", e.Row.DataKey("CveIE"), e.Row.DataKey("Folio"))
Else
e.Row.FCLiteral("LtlFactura").Text = String.Format("<a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">{1}</a>", e.Row.DataKey("CveVenta"), e.Row.DataKey("Folio"))
End If
If e.Row.DataKey("ISTotal") = "1" Then
e.Row.Cells(0).Visible = False
e.Row.Cells(1).ColumnSpan = 3
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Right
e.Row.FCLiteral("LtlFactura").Text = String.Format("Total {0} ", e.Row.DataKey("Tipo"))
e.Row.BackColor = Drawing.Color.LightGray
e.Row.Cells(2).Visible = False
e.Row.FCTextBox("TxtAnticipo" & e.Row.RowIndex).Visible = False
e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Visible = False
e.Row.FCLabel("LblTotalAnticipos").Visible = True
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right
End If
If UsuarioActual.Empresa.Funcionalidad(185) = "1" Then
If e.Row.DBCampo("Tipo").ToString().Contiene("Ant", "IxC") AndAlso Not CBool(e.Row.DBCampo("AnticipoAutorizado")) Then
e.Row.FCCheckBox("Chk" & e.Row.RowIndex).Enabled = False
e.Row.FCCheckBox("Chk" & e.Row.RowIndex).ToolTip = "Anticipo Bloqueado"
e.Row.FCLinkButton("LnkSolicitarActivarAnticipo").Visible = True
End If
End If
If e.Row.DBCampo("CveMoneda").ToString().ToEntero() = 1 Then
e.Row.FCTextBox("TxtTC" & e.Row.RowIndex).Visible = False
End If
End If
End Sub
Protected Sub BtnAceptarAnticipos_Click(sender As Object, e As System.EventArgs) Handles BtnAceptarAnticipos.Click
If DdlTipoAmortizacionAnticipo.SelectedValue.ToEntero() <= 0 Then
Alert("Debe seleccionar un tipo de amortización", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim Amortizacion As Decimal = 0
'cuando es PAGO CON DEVOLUCION
Dim SbObs As New StringBuilder
For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then
Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal
End If
Next
If Amortizacion > 0 Then
TxtAnticipos.Text = Amortizacion.ToString()
LtlTipoAnticipo.Text = DdlTipoAmortizacionAnticipo.SelectedItem.Text
HdnTipoAmortizacion.Value = DdlTipoAmortizacionAnticipo.SelectedValue
Else
TxtAnticipos.Text = ""
LtlTipoAnticipo.Text = ""
HdnTipoAmortizacion.Value = ""
End If
RegistraScript("$('#DivAnticipos').modal('hide');CalculaTotalPagoContado()", "AE")
UpL.Update()
End Sub
Protected Sub DdlTipoAmortizacionAnticipo_SelectedIndexChanged(sender As Object, e As EventArgs)
divAmortizacionTipoRelacion.Visible = DdlTipoAmortizacionAnticipo.SelectedValue = "2"
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
CargaDdlNCPS()
DivConceptoNC.Visible = True
Else
DivConceptoNC.Visible = False
End If
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero
Dim DbRowVenta As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) Then
DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
End If
ObjVentas.Dispose()
If DbRowVenta IsNot Nothing Then
CargaAnticipos(DbRowVenta("CveCliente").ToString().ToEntero())
End If
UpAnticipos.Update()
End Sub
Public Sub CargaDdlNCPS()
Dim CveSATNC As String = "84111506"
Dim dtt As New DataTable
dtt = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CodigoSATPS:=CveSATNC, AplicaParaVenta:=1) ', SATClavePS:=CveSATNC
If dtt IsNot Nothing Then
DdlNCPSAnt.DataSource = dtt
DdlNCPSAnt.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlNCPSAnt.DataBind()
dtt.Dispose()
End If
End Sub
End Class