This commit is contained in:
2024-02-28 20:16:09 -07:00
16 changed files with 654 additions and 182 deletions

View File

@@ -1613,7 +1613,7 @@
<td style="border: 1px none white"><b>Amort. Ant.:</b></td>
<td>
<asp:Label ID="LblAmortizacion" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00" Width="78px"></asp:Label></td>
<td align="right">&nbsp;<asp:LinkButton ID="ImgAntiPend" runat="server" Text=" <i class='fa fa-money font-green'></i> " AlternateText="Cancelación de Anticipos" Style="cursor: pointer;" />
<td align="right">&nbsp;<asp:LinkButton ID="ImgAntiPend" runat="server" OnClick="ImgAntiPend_Click" Text=" <i class='fa fa-money font-green'></i> " AlternateText="Cancelación de Anticipos" Style="cursor: pointer;" />
</td>
</tr>
@@ -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;

View File

@@ -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))
@@ -2311,6 +2320,21 @@ Partial Class Ventas
End Property
Public Property CveAlamcenFiltroDdl As Integer
Get
If ViewState("CveAlamcenFiltroDdl") Is Nothing Then
ViewState("CveAlamcenFiltroDdl") = -1
End If
Return ViewState("CveAlamcenFiltroDdl").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveAlamcenFiltroDdl") = value
End Set
End Property
#Region "VENTA MEDICA"
Property EsVentaMedica As Boolean
@@ -2572,7 +2596,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();")
@@ -4913,6 +4937,13 @@ Partial Class Ventas
End If
End If
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
TxtAlfa1.Text = DbRowVenta("Alfa1").ToString
End If
End Using
End If
@@ -8041,8 +8072,16 @@ Partial Class Ventas
Objeto.ddlWS.Attributes.Add("data-pagina", "ventas/ventas")
Objeto.ddlWS.Attributes.Add("data-AplicaparaVenta", "1")
End If
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
Objeto.Attributes.Add("data-CveAlmacen", $"{CveAlamcenFiltroDdl}")
Objeto.ddlWS.Attributes.Add("data-CveAlmacen", $"{CveAlamcenFiltroDdl}")
End If
End If
End Sub
Private Sub CargaPSRemision(CveClasificacion As Integer, Objeto As ADServerControl.Dropdownlost)
@@ -13471,7 +13510,17 @@ Partial Class Ventas
If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso EsVentaMedica Then
CveAlmacenTraspasoDestino = CveAlmacenAsignado
If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then
Dim objclientes As New ClsClientes
If objclientes.GetSucursales(CveCliente, -1) Then
CveAlmacenTraspasoDestino = objclientes.DtResultados.FiltroPrimeroValor("CveAlmacenAsignado", $" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}").ToEntero
End If
objclientes.Dispose()
End If
If Not CveAlmacenTraspasoDestino > 0 Then
CveAlmacenTraspasoDestino = CveAlmacenAsignado
End If
If RBLTipoVenta.SelectedValue.ToEntero = 2 Then
If Not ChkRequiereTecnico.Checked Then
@@ -14785,6 +14834,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
@@ -15370,6 +15424,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
@@ -16054,7 +16151,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
@@ -16161,7 +16260,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
@@ -16173,6 +16272,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()
@@ -16466,7 +16569,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
@@ -16612,6 +16715,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
@@ -21505,22 +21629,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
@@ -30502,6 +30628,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
@@ -36461,9 +36603,10 @@ Partial Class Ventas
DdlProcedimiento.SelectedValueExist(dRow("CveProcedimiento").ToString.ToEntero)
TxtPaciente.Text = dRow("Paciente").ToString
TxtEpisodio.Text = dRow("Episodio").ToString
SeEstaFActurandoVentaMedica = True
TxtAlfa1.Text = dRow("Alfa1").ToString
CveTipoVenta = dRow("CveTipoVenta").ToString.ToEntero
ChkRequiereTecnico_CheckedChanged(Nothing, Nothing)
SeEstaFActurandoVentaMedica = True
End If
objVenta.Dispose()
End If
@@ -36533,34 +36676,6 @@ Partial Class Ventas
End Sub
'Private Sub CargaSucursalesModal(CveClienteSeleccionado As Integer)
' DdlSucursalClienteModal.Items.Clear()
' DdlSucursalClienteModal.ClearSelection()
' DdlSucursalClienteModal.SelectedValue = Nothing
' Dim ObjCliente As New ClsClientes
' If ObjCliente.GetSucursales(CveClienteSeleccionado) Then
' DdlSucursalClienteModal.DataSource = ObjCliente.DtResultados
' If ObjCliente.DtResultados.Rows.Count > 0 Then
' DvModalClientesucursal.Visible = True
' Else
' DvModalClientesucursal.Visible = False
' End If
' Else
' DvModalClientesucursal.Visible = False
' DdlSucursalClienteModal.DataSource = Nothing
' End If
' ObjCliente.Dispose()
' DdlSucursalClienteModal.DataBind()
' DdlSucursalClienteModal.Items.Insert(0, New ListItem("Matriz", "-1"))
' UpDvModalTipoVenta.FindDataSourceControl
'End Sub
Private Sub CargaDdlClientesSucursal()
@@ -36657,13 +36772,6 @@ Partial Class Ventas
UpDvModalTipoVenta.Update()
End Sub
'Protected Sub DdlClientesWS_selectedindexchange(sender As Object, e As EventArgs)
' CargaPSProcedimiento(DdlProcedimiento.SelectedValue.ToEntero, DdlClientesWS.SelectedValue.ToEntero, DdlSubProyectoDatos.SelectedValue.ToEntero)
' 'CargaSucursalesModal(DdlClientesWS.SelectedValue.ToEntero)
'End Sub
Protected Sub DdlClienteSucursal_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim CveClienteSplit As Integer = -1
@@ -36727,9 +36835,7 @@ Partial Class Ventas
ChkRequiereTecnicoModal.Enabled = True
'DdlClientesWS.txtText.Value = ""
'DdlClientesWS.txtValue.Value = ""
'DdlClientesWS.ddl.SelectedValueExist(-1)
DdlClienteSucursal.SelectedValueExist(-1)
DvModalRequiereOSFecha.Visible = False
@@ -36791,8 +36897,6 @@ Partial Class Ventas
End If
End If
For Each GvRow As GridViewRow In GvProductosProcedimiento.Rows
Dim Cantidad As Decimal = GvRow.FCTextBox("TxtCantidad").Text.ToDecimal
Dim CveUnidadMedida As Integer = GvRow.DataKey("CveUnidadMedida").ToEntero
@@ -36874,6 +36978,9 @@ Partial Class Ventas
End If
DdlTipoComprobante.Enabled = False
CargaCliente(CveCliente)
@@ -36926,10 +37033,17 @@ Partial Class Ventas
UpParametros.Update()
End If
If RBLTipoVenta.SelectedValue.Contiene("5", "6") Then
AsignaAlamacenWS()
CargaPS(-1, DdlPS)
End If
RegistraScript("$('#DvModalTipoVenta').modal('hide');")
UpCliente.Update()
End Sub
Protected Sub GvProductosProcedimiento_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataKey("Precio").ToDecimal = 0 Then
@@ -37089,6 +37203,27 @@ Partial Class Ventas
CargaProcedimientos(HdnCveProcedimientoNuevo.Value.ToEntero)
End Sub
Private Sub AsignaAlamacenWS()
CveAlamcenFiltroDdl = -1
If UsuarioActual.Empresa.Funcionalidad(578).ToEntero = 1 Then
If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then
Dim objclientes As New ClsClientes
If objclientes.GetSucursales(CveCliente, -1) Then
CveAlamcenFiltroDdl = objclientes.DtResultados.FiltroPrimeroValor("CveAlmacenAsignado", $" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}").ToEntero
End If
objclientes.Dispose()
End If
If Not CveAlamcenFiltroDdl > 0 Then
CveAlamcenFiltroDdl = If(CveAlmacenAsignado > 0, CveAlmacenAsignado, -1)
End If
End If
End Sub
#End Region
'Protected Sub LnkCancelarSoloCFDI_Click(sender As Object, e As EventArgs)
@@ -37215,5 +37350,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