diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx
index 65aa3a9ca..1dcf43f65 100644
--- a/Ventas/Ventas.aspx
+++ b/Ventas/Ventas.aspx
@@ -1613,7 +1613,7 @@
Amort. Ant.: |
|
-
+ |
|
@@ -10247,7 +10247,7 @@
$get("HdnTipoDescuento").value = "3";
//si es con.nc,es.el.total
- var Total = ToDouble($get(TipoAnticipo == 2 ? 'TxtTotal' : 'TxtSubTotal').value);
+ var Total = ToDouble($get((TipoAnticipo == 2 || TipoAnticipo == 4) ? 'TxtTotal' : 'TxtSubTotal').value);
var SaldoCompra = parseFloat(parseFloat($get('HdnVentaSaldo').value).toFixed(2));
if (ToDouble($get('HdnCveVenta').value) == 0) SaldoCompra = Total;
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index d0c65fca6..5636dd9da 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -157,6 +157,15 @@ Partial Class Ventas
End Set
End Property
+ 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 TmpDTError As DataTable
Get
Return If(IsNothing(ViewState("TmpDTError")), Nothing, CType(ViewState("TmpDTError"), DataTable))
@@ -2572,7 +2581,7 @@ Partial Class Ventas
ImgDescTotal.Visible = False
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 = '';")
- ImgAntiPend.Attributes.Add("onclick", "$get('HdnTipoDescuento').value = '3'; MuestraAnticipos();")
+ 'ImgAntiPend.Attributes.Add("onclick", "$get('HdnTipoDescuento').value = '3'; MuestraAnticipos();")
ImgOtrosConceptos.Attributes.Add("onclick", "javascript:$('#ModalOtrosConceptos').modal();")
'LkbAgregarComplementos.Attributes.Add("onclick", "javascript:$('#ModalComplementos').modal();")
'ImgCerrar.Attributes.Add("OnClick", "$('#DivAnticipos').hide();")
@@ -3532,11 +3541,11 @@ Partial Class Ventas
Private Sub ValidaUsuarioAcceso()
'VERIFICAR SI LA SESION SE ENCUENTRA BLOQUEADA
If UsuarioActual.Empresa.Funcionalidad(599) = "1" Then
- Dim DrUsuario As DataRow = GlobalDTUsuarios(CveUsuario:=UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)
+ Dim DrUsuario As DataRow = GlobalDTUsuarios(CveUsuario:=UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("")
- If DrUsuario("CodigoAcceso").ToString() <> "" Then
+ If DrUsuario IsNot Nothing AndAlso DrUsuario("CodigoAcceso").ToString() <> "" Then
If UsuarioActual.SesionBloqueada Then
- DivBloqueoacceso.Visible = False
+ DivBloqueoAcceso.Visible = False
Dim strScript As New StringBuilder
strScript.Append("window.onload = function MuestraBloqueo() { document.getElementById(""C_BtnShowBloqueoAcceso"").click(); setTimeout(function(){ $('#C_TxtCodigoAcceso').focus(); ")
If UsuarioActual.ErrorDesbloqueo Then
@@ -3553,10 +3562,10 @@ Partial Class Ventas
BtnEmitirImprimir.Visible = False
Exit Sub
Else
- DivBloqueoacceso.Visible = True
+ DivBloqueoAcceso.Visible = True
End If
Else
- DivBloqueoacceso.Visible = False
+ DivBloqueoAcceso.Visible = False
End If
Else
DivBloqueoacceso.Visible = False
@@ -14777,6 +14786,11 @@ Partial Class Ventas
Next
Else
+
+ 'If DdlTipoAmortizacionAnticipo.SelectedValue <> "4" Then
+
+ 'End If
+
For Each row2 As GridViewRow In GVAnticipos.Rows
If row2.DataKey("CveConceptoContable").ToString().ToEntero() = 12 Then
@@ -15362,6 +15376,49 @@ Partial Class Ventas
End If
End If
+
+ 'If Not ErrorPrepoliza AndAlso UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso ObjFactura.TipoDocto = "Ing" AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "4" AndAlso ObjFactura.CveMoneda = 1 Then
+
+ ' For Each row2 As GridViewRow In GVAnticipos.Rows
+ ' If row2.DataKey("CveConceptoContable").ToString().ToEntero() = 12 Then
+ ' If row2.FCCheckBox("Chk" & row2.RowIndex).Checked Then
+
+ ' importeMovimiento = row2.FCTextBox("TxtAnticipo" & row2.RowIndex).Text.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.DataKey("CveMoneda").ToString().ToEntero()
+
+ ' Dim ObjFacturaRef As New Modelos.Factura(UsuarioActual, row2.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
+
+ ' Dim ventaRef As New Venta(ObjFacturaRef, UsuarioActual)
+
+ ' ObjFacturaRef.Dispose()
+
+ ' If ventaRef.TipoDocto = "Dev" Then
+ ' Dim Pago As New VentaPago
+ ' Pago.Fecha = ObjFactura.Fecha
+ ' Pago.FechaDocumentoRelacionado = ObjFactura.Fecha
+ ' Pago.ImportePagoVenta = importeMovimiento
+ ' Pago.ImportePago = importeMovimiento
+ ' Pago.CveMonedaPago = ObjFactura.CveMoneda
+ ' Pago.TCPago = ObjFactura.TipoCambio
+ ' Pago.TipoPago = "NC"
+ ' Pago.CveVentaAmortizacion = ObjFactura.CveVenta 'Dr("CveVenta").ToString().ToEntero()
+ ' Pago.AplicaTraslado = False
+ ' Pago.Referencia = Concepto
+ ' 'Pago.CveConceptoPago = 251
+ ' ErrorPrepoliza = AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta)
+
+ ' Else
+ ' ErrorPrepoliza = True
+ ' ErrorList.Add("No se puede aplicar un documento diferente a una devolución")
+ ' End If
+
+ ' End If
+ ' End If
+ ' Next
+ 'End If
+
If ObjConta.ValidacionesPrePoliza(ObjFactura.CvePrePoliza, UsuarioActual, Opcion:=2, AutoConta:=AutoConta) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
If ObjConta.ValorPolizaDescuadre = 2 Then
@@ -16046,7 +16103,9 @@ Partial Class Ventas
Dim ObjMovtos As New ClsMovimientos()
If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente) Then
- Dim DtMovtos As DataTable = ObjMovtos.DtResultados.FiltraParametros($"Saldo > 0 AND SaldoSubtotal > 0 {If(CveVenta < 0, $"AND Tipo = 'Ant' ", "")} {If(DdlTipoComprobante.SelectedValue = "Ant", "AND Tipo = 'NC'", "")}")
+ Me.TmpDTAnticiposNCIxCCliente = ObjMovtos.DtResultados.Copy()
+ Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND SaldoSubtotal > 0 {If(CveVenta < 0, $"AND Tipo = 'Ant' ", "")} {If(DdlTipoComprobante.SelectedValue = "Ant", "AND Tipo = 'NC'", "")}")
+
If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then
DtMovtos = DtMovtos.FiltraParametros($"{If(CveVenta < 0, $"Tipo = 'Ant'{If(DdlTipoComprobante.SelectedValue = "Ing", $" AND CveMoneda ={DdlMoneda.SelectedValue.ToEntero()}", "")} ", "")}")
End If
@@ -16153,7 +16212,7 @@ Partial Class Ventas
saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
If CveVenta <= 0 Then
- If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then 'cuando es por NC, debe de tomar el total de su saldo respectivo
+ If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("2") Then 'cuando es por NC, debe de tomar el total de su saldo respectivo
saldo = e.Row.DataKey("SaldoConImpuestos").ToString().ToDecimal
Else
saldo = e.Row.DataKey("SaldoSubTotal").ToString().ToDecimal
@@ -16165,6 +16224,10 @@ Partial Class Ventas
e.Row.FCLiteral("LtlAnticipos").Text = saldo.FormatoNumero
End If
+ If CveVenta <= 0 AndAlso DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("4") Then
+ saldo = e.Row.DataKey("Saldo").ToString().ToDecimal
+ End If
+
End If
saldo = saldo.RoundSQL()
@@ -16458,7 +16521,7 @@ Partial Class Ventas
'cuando no se ha registrado la venta
- If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("1", "2", "3") Then
+ If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("1", "2", "3", "4") Then
Dim Amortizacion As Decimal = 0
Dim ImpuestosLocalesTemporal As Decimal = 0
@@ -16604,6 +16667,27 @@ Partial Class Ventas
HdnTieneAnticiposVinculados.Value = "1"
End If
+
+
+ 'cuando es PAGO CON DEVOLUCION
+ If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
+
+ For Each gvr As GridViewRow In GVAnticipos.Rows
+ If gvr.FCCheckBox("Chk" & gvr.RowIndex) IsNot Nothing AndAlso gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked AndAlso gvr.DataKey("CveConceptoContable").ToEntero().Contiene(12) Then
+ Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal ' - ((gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("TotalAnticipo").ToDecimal) * gvr.DataKey("IVAAnticipo").ToDecimal)
+ End If
+ Next
+
+ LblAntAplicados.Text = String.Format("Pago con devolución: {0:C}", Amortizacion) : LblAntAplicados.Visible = True
+ HdnAnticipos.Value = Amortizacion.RoundSQL(2).ToString()
+ Amortizacion = 0
+ HdnTipoDescuento.Value = "-1"
+ HdnDescuento.Value = "0"
+ RegistraScript("BorraDescuentos();")
+ HdnTieneAnticiposVinculados.Value = "1"
+ End If
+
+
CalculaTotalesVenta(ValidarDescuentos:=True)
End If
End If
@@ -21497,22 +21581,24 @@ Partial Class Ventas
Exit Sub
End If
- Dim ObjContrato As New ClsContratos
- If ObjContrato.GetEstimacionesPorFacturar(-1, CveCliente, DdlContrato.SelectedValue.ToEntero(), 0, UsuarioActual.CveEmpresa) Then
- GvEst.DataSource = ObjContrato.DtResultados
- If ObjContrato.DtResultados.Rows.Count > 0 Then
- 'BtnEstimacion.Visible = True
- DdlContrato.Items.Clear()
- DdlContrato.Items.Add(New ListItem("Todos", "-1"))
- DdlContrato.DataSource = ObjContrato.DtResultados.FiltraParametros("CveContrato > 0", "NumeroContrato", DistinctColumns:={"CveContrato", "NumeroContrato"})
+ If DdlContrato.SelectedValue.ToEntero() > 0 Then
+ Dim ObjContrato As New ClsContratos
+ If ObjContrato.GetEstimacionesPorFacturar(-1, CveCliente, DdlContrato.SelectedValue.ToEntero(), 0, UsuarioActual.CveEmpresa) Then
+ GvEst.DataSource = ObjContrato.DtResultados
+ If ObjContrato.DtResultados.Rows.Count > 0 Then
+ 'BtnEstimacion.Visible = True
+ DdlContrato.Items.Clear()
+ DdlContrato.Items.Add(New ListItem("Todos", "-1"))
+ DdlContrato.DataSource = ObjContrato.DtResultados.FiltraParametros("CveContrato > 0", "NumeroContrato", DistinctColumns:={"CveContrato", "NumeroContrato"})
+ End If
End If
+
+ ObjContrato.Dispose()
+
+ DdlContrato.DataBind()
+ GvEst.DataBind()
End If
- ObjContrato.Dispose()
-
- DdlContrato.DataBind()
- GvEst.DataBind()
-
UPEstimaciones.Update()
End Sub
@@ -30494,6 +30580,22 @@ Partial Class Ventas
divAnticipoMsg.Visible = False
+ If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
+ If DdlTipoComprobante.SelectedValue = "Ing" AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
+ Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 And SaldoSubtotal > 0 {If(CveVenta < 0, $"AND Tipo = 'NC' ", "")}")
+ divAmortizacionTipoRelacion.Visible = False
+ GVAnticipos.DataSource = DtMovtos
+ GVAnticipos.DataBind()
+ Else
+ Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND SaldoSubtotal > 0 {If(CveVenta < 0, $"AND Tipo = 'Ant' ", "")} {If(DdlTipoComprobante.SelectedValue = "Ant", "AND Tipo = 'NC'", "")}")
+ divAmortizacionTipoRelacion.Visible = True
+ If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then
+ DtMovtos = DtMovtos.FiltraParametros($"{If(CveVenta < 0, $"Tipo = 'Ant'{If(DdlTipoComprobante.SelectedValue = "Ing", $" AND CveMoneda ={DdlMoneda.SelectedValue.ToEntero()}", "")} ", "")}")
+ End If
+ End If
+ End If
+
+
If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("1", "2") Then
'cuando es amortización por descuento, debe tener seleccionado descuentos previamente registrados
If DdlTipoAmortizacionAnticipo.SelectedValue = "1" AndAlso LblDescuentos.Text.ToDecimal <= 0 Then
@@ -37207,5 +37309,26 @@ Partial Class Ventas
End If
End Using
End Sub
+ Protected Sub ImgAntiPend_Click(sender As Object, e As EventArgs)
+ ' $get('HdnTipoDescuento').value = '3'; MuestraAnticipos();
+ HdnTipoDescuento.Value = "3"
+
+ If UsuarioActual.Empresa.Funcionalidad(109) = "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")
+
+ DdlTipoAmortizacionAnticipo_SelectedIndexChanged(DdlTipoAmortizacionAnticipo, EventArgs.Empty)
+
+ divAmortizacionTipoRelacion.Visible = False
+ End If
+
+ UpAnticipos.Update()
+
+ RegistraScript("MuestraAnticipos();", "AE")
+ End Sub
End Class