--FIX generacion de NC en cobranza

This commit is contained in:
2024-10-21 11:48:27 -07:00
parent 909036cb12
commit 4a78544929
3 changed files with 158 additions and 80 deletions

View File

@@ -742,7 +742,7 @@ Namespace Modelos
Return Not ErrorPrePolizas
End Function
Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Transac As SqlClient.SqlTransaction = Nothing, Optional Modulo As String = "Modelos/GuardarVentaM") As MMensajeFactura
Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Transac As SqlClient.SqlTransaction = Nothing, Optional Modulo As String = "Modelos/GuardarVentaM", Optional MostrarURL As Boolean = False) As MMensajeFactura
Dim Retorno As New MMensajeFactura()
If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then
@@ -1117,8 +1117,12 @@ Namespace Modelos
End If
'MENSAJE PRINCIPAL
MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio))
If MostrarURL Then
MensajeAlert.AppendFormat("<br/>La {0}: <a class=""Texto"" target=""_blank"" href=""/Ventas/Ventas.aspx?CveVenta={2}""><b></b>{1}</a> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio, Me.CveVenta)
Else
MensajeAlert.AppendFormat(String.Format("<br/>La {0}: <b>{1}</b> se generó correctamente.<br/><br/>", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio))
End If
' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA
If SeTimbro Then

View File

@@ -535,8 +535,8 @@
</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=".," />
<asp:TextBox ID="TxtNCDev" 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="TxtNCDev" FilterType="Custom, Numbers" ValidChars=".," />
</div>
<div class="col-md-6">
<label>
@@ -1130,7 +1130,6 @@
<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>
@@ -1389,7 +1388,7 @@
let total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado;
if (<%= If(UsuarioActual.Empresa.CveEmpresa = 189, 1, 0)%> == 1) {
var totalAnticipos = ToDouble($get("TxtAnticipos").value);
let totalAnticipos = ToDouble($get("TxtNCDev").value);
total = total + totalAnticipos;
}

View File

@@ -9,6 +9,18 @@ Imports Modelos.Factura
Partial Class Ventas_PVCobranza
Inherits ClsPaginas
Private Property CveCliente As Integer
Get
If ViewState("CveCliente") Is Nothing Then
ViewState("CveCliente") = -1
End If
Return ViewState("CveCliente").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCliente") = value
End Set
End Property
Private Property TmpDTAnticiposNCIxCCliente As DataTable
Get
Return If(IsNothing(ViewState("TmpDTAnticiposNCIxCCliente")), Nothing, CType(ViewState("TmpDTAnticiposNCIxCCliente"), DataTable))
@@ -16,6 +28,15 @@ Partial Class Ventas_PVCobranza
Set(value As DataTable)
ViewState("TmpDTAnticiposNCIxCCliente") = value
End Set
End Property
Private Property ListaAnticiposAplicados As List(Of Modelos.MAnticipoRelacionado)
Get
Return If(IsNothing(ViewState("ListaAnticiposAplicados")), Nothing, CType(ViewState("ListaAnticiposAplicados"), List(Of Modelos.MAnticipoRelacionado)))
End Get
Set(value As List(Of Modelos.MAnticipoRelacionado))
ViewState("ListaAnticiposAplicados") = value
End Set
End Property
Private Property CveCorte As Integer
@@ -86,8 +107,6 @@ 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
@@ -282,16 +301,6 @@ Partial Class Ventas_PVCobranza
ObjMovtos.Dispose()
GvDatos.DataBind()
TxtImporteEfectivo.Text = ""
TxtImporteCredito.Text = ""
TxtImporteDebito.Text = ""
TxtImporteCheque.Text = ""
TxtImporteTransferencia.Text = ""
TxtImporteOtrosContado.Text = ""
TxtCambio.Text = ""
TxtClaveAutorizacion.Text = ""
TxtAutorizo.Text = ""
UpL.Update()
End Sub
@@ -395,6 +404,12 @@ Partial Class Ventas_PVCobranza
LtlNombre.Text = GvRow.DataKey("AtencionA")
LtlFolio.Text = GvRow.DataKey("SerieFolio")
LtlSaldo.Text = GvRow.DataKey("Saldo").ToDecimal.FormatoNumero
If UsuarioActual.CveEmpresa = 189 AndAlso GvRow.DataKey("TipoDocto") = "Rem" Then
DivAnticipo.Visible = True
ImgAntiPend.Visible = True
End If
Catch ex As Exception
TieneError = True
End Try
@@ -419,7 +434,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 + TxtAnticipos.Text.ToDecimal()
Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal + TxtNCDev.Text.ToDecimal()
If Pagado = 0 Then
Alert("Favor de especificar importe", TipoMensaje.ToastAdventencia)
Exit Sub
@@ -618,11 +633,11 @@ Partial Class Ventas_PVCobranza
ObjVentas2.Commit()
Dim msBuild As New StringBuilder()
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
If respFactura IsNot Nothing Then
If Not respFactura.Factura.TimbrarFactura() Then
msBuild.Append("La factura no se pudo timbrar<br/> ")
End If
End If
'If respFactura IsNot Nothing Then
' If Not respFactura.Factura.TimbrarFactura() Then
' msBuild.Append("La factura no se pudo timbrar<br/> ")
' End If
'End If
If respFactura IsNot Nothing Then
msBuild.Append($"Pago Registrado correctamente.")
@@ -672,8 +687,34 @@ Partial Class Ventas_PVCobranza
Private Sub LimpiarDatos()
PnlContado.Visible = False
HdnCveVenta.Value = ""
HdnTipoAmortizacion.Value = ""
TxtImporteEfectivo.Text = ""
TxtImporteCredito.Text = ""
TxtImporteDebito.Text = ""
TxtImporteCheque.Text = ""
TxtImporteTransferencia.Text = ""
TxtImporteOtrosContado.Text = ""
TxtCambio.Text = ""
TxtClaveAutorizacion.Text = ""
TxtAutorizo.Text = ""
TxtNCDev.Text = ""
LtlTipoAnticipo.Text = ""
HdnTipoAmortizacion.Value = ""
CveCliente = -1
If TmpDTAnticiposNCIxCCliente IsNot Nothing Then
TmpDTAnticiposNCIxCCliente.Clear()
TmpDTAnticiposNCIxCCliente = Nothing
End If
If ListaAnticiposAplicados IsNot Nothing Then
ListaAnticiposAplicados.Clear()
ListaAnticiposAplicados = Nothing
End If
ImgAntiPend.Visible = False
DivAnticipo.Visible = False
UpL.Update()
End Sub
Private Function GenerarFactura(ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes) As Modelos.Factura.MMensajeFactura
@@ -755,7 +796,7 @@ Partial Class Ventas_PVCobranza
Dim SbAlert As New StringBuilder()
Try
Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta")
Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
Retorno.Factura = ObjFactura
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
@@ -826,7 +867,7 @@ Partial Class Ventas_PVCobranza
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 Total As Decimal = TxtNCDev.Text.ToDecimal()
Dim subTotal As Decimal = (Total / (1D + Venta.PorcentajeIVA))
'Dim IVA = (subTotal * Factura.PorcentajeIVA).RoundSQL(2)
Dim PU As Decimal = subTotal
@@ -874,7 +915,7 @@ Partial Class Ventas_PVCobranza
Dim CveConceptoContable = GvRow.DataKey("CveConceptoContable").ToEntero()
Dim CveIE = GvRow.DataKey("CveIE").ToEntero()
Dim FolioFiscal = ""
Dim FolioFiscal = GvRow.DataKey("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()
@@ -893,7 +934,7 @@ Partial Class Ventas_PVCobranza
Dim SbAlert As New StringBuilder()
Try
Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta")
Retorno = ObjNC.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
Retorno.Factura = ObjNC
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
@@ -1392,23 +1433,24 @@ Partial Class Ventas_PVCobranza
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 CveCliente <= 0 Then
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())
If DbRowVenta IsNot Nothing Then
CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
End If
End If
If CveCliente > 0 Then
CargaAnticipos(CveCliente)
End If
UpAnticipos.Update()
@@ -1446,12 +1488,12 @@ Partial Class Ventas_PVCobranza
ObjMovtos.Dispose()
If Me.TmpDTAnticiposNCIxCCliente IsNot Nothing Then
Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND Tipo IN('RNC','IxC','Ant') ")
Dim DtMovtos As DataTable = Me.TmpDTAnticiposNCIxCCliente.FiltraParametros($"Saldo > 0 AND Tipo IN('NC','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
If DdlTipoAmortizacionAnticipo.SelectedValue = "4" Then
GVAnticipos.DataSource = DtMovtos.FiltraParametros("Tipo IN('NC','IxC')")
Else
GVAnticipos.DataSource = DtMovtos.FiltraParametros("Tipo IN('Ant')")
End If
Else
GVAnticipos.DataSource = Nothing
@@ -1476,30 +1518,44 @@ Partial Class Ventas_PVCobranza
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())
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
If CveCliente <= 0 Then
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
CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
End If
End If
If CveCliente > 0 Then
CargaAnticipos(CveCliente)
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())
Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero()
If CveCliente <= 0 Then
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
CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
End If
End If
If CveCliente > 0 Then
CargaAnticipos(CveCliente)
End If
End Sub
@@ -1639,20 +1695,32 @@ Partial Class Ventas_PVCobranza
Dim Amortizacion As Decimal = 0
If ListaAnticiposAplicados Is Nothing Then
ListaAnticiposAplicados = New List(Of Modelos.MAnticipoRelacionado)
Else
ListaAnticiposAplicados.Clear()
End If
'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
If gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal > 0 Then
Amortizacion += gvr.FCTextBox(String.Format("TxtAnticipo{0}", gvr.RowIndex)).Text.ToDecimal()
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = gvr.DataKey("CveVenta").ToEntero(), .FolioFiscal = gvr.DataKey("FolioFiscal")})
End If
End If
End If
Next
If Amortizacion > 0 Then
TxtAnticipos.Text = Amortizacion.ToString()
TxtNCDev.Text = Amortizacion.ToString()
LtlTipoAnticipo.Text = DdlTipoAmortizacionAnticipo.SelectedItem.Text
HdnTipoAmortizacion.Value = DdlTipoAmortizacionAnticipo.SelectedValue
Else
TxtAnticipos.Text = ""
TxtNCDev.Text = ""
LtlTipoAnticipo.Text = ""
HdnTipoAmortizacion.Value = ""
End If
@@ -1671,16 +1739,23 @@ Partial Class Ventas_PVCobranza
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 CveCliente <= 0 Then
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())
If DbRowVenta IsNot Nothing Then
CveCliente = DbRowVenta("CveCliente").ToString().ToEntero()
End If
End If
If CveCliente > 0 Then
CargaAnticipos(CveCliente)
End If
UpAnticipos.Update()