-
This commit is contained in:
@@ -397,7 +397,7 @@ Partial Class Ventas_PVCobranza
|
||||
If DbRowVenta IsNot Nothing Then
|
||||
Dim VentaActual As New Venta(UsuarioActual)
|
||||
VentaActual.CveVenta = CveVenta
|
||||
|
||||
VentaActual.TipoDocto = DbRowVenta("TipoDocto").ToString
|
||||
VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate
|
||||
VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero
|
||||
VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
|
||||
@@ -422,10 +422,30 @@ Partial Class Ventas_PVCobranza
|
||||
Dim SaldoTotalInicial As Decimal = DbRowVenta("Saldo").ToString.ToDecimal
|
||||
Dim PagoAplicado As Decimal = 0
|
||||
|
||||
Dim ObjConta As New ClsContabilidad
|
||||
Dim ObjIE As New ClsBancos(ObjConta.IniciaTransacSQL())
|
||||
Dim ObjVentas2 As New ClsVentas(ObjConta.IniciaTransacSQL())
|
||||
Dim ObjVentas2 As New ClsVentas()
|
||||
Dim ObjIE As New ClsBancos(ObjVentas2.IniciaTransacSQL())
|
||||
Dim ObjConta As New ClsContabilidad(ObjVentas2.IniciaTransacSQL())
|
||||
Dim ObjClientes As New ClsClientes(ObjVentas2.IniciaTransacSQL())
|
||||
|
||||
Dim respFactura As Modelos.Factura.MMensajeFactura = Nothing
|
||||
|
||||
Try
|
||||
'FACTURAR LA REMISION PARA HACER EL PAGO
|
||||
If UsuarioActual.CveEmpresa = 193 AndAlso VentaActual.TipoDocto = "Rem" Then
|
||||
respFactura = GenerarFactura(VentaActual, ObjVentas2, ObjClientes)
|
||||
|
||||
If respFactura Is Nothing Then
|
||||
MsgError = "Ocurrío un error al generar la factura"
|
||||
ElseIf (respFactura IsNot Nothing AndAlso respFactura.Mensajes.Count > 0) AndAlso respFactura.TieneError Then
|
||||
MsgError = respFactura.Mensajes(0)
|
||||
End If
|
||||
|
||||
'REALIZAR EL PAGO EN LA FACTURA
|
||||
If respFactura IsNot Nothing AndAlso Not respFactura.TieneError Then
|
||||
CveVenta = respFactura.CveVenta
|
||||
End If
|
||||
End If
|
||||
|
||||
CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
||||
|
||||
If CvePrePoliza > 0 Then
|
||||
@@ -487,21 +507,41 @@ Partial Class Ventas_PVCobranza
|
||||
End Try
|
||||
|
||||
If MsgError = "" Then
|
||||
ObjConta.Commit()
|
||||
Alert($"Pago Registrado correctamente.<br/><br/> <a href=""/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1&TICKET=1®ENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>", TipoMensaje.MsgInformacion)
|
||||
ObjVentas2.Commit()
|
||||
|
||||
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
|
||||
If respFactura IsNot Nothing Then
|
||||
If Not respFactura.Factura.TimbrarFactura() Then
|
||||
Alert("La factura no se pudo timbrar", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim msBuild As New StringBuilder()
|
||||
|
||||
If respFactura IsNot Nothing Then
|
||||
msBuild.Append($"Pago Registrado correctamente.")
|
||||
For Each m In respFactura.Mensajes
|
||||
msBuild.AppendFormat("<br/> {0}", m)
|
||||
Next
|
||||
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®ENERAR=1", CveVenta))}"" class='Texto'>Imprimir ticket</a>")
|
||||
End If
|
||||
|
||||
Alert(msBuild.ToString(), TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
ObjConta.RollBack()
|
||||
ObjVentas2.RollBack()
|
||||
Alert(MsgError, TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjVentas2.Dispose()
|
||||
ObjConta.Dispose()
|
||||
ObjIE.Dispose()
|
||||
ObjVentas2.Dispose()
|
||||
ObjClientes.Dispose()
|
||||
|
||||
If MsgError = "" Then
|
||||
Try
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
|
||||
ImpresionDirectaPDF(HdnCveVenta.Value.ToEntero)
|
||||
ImpresionDirectaPDF(CveVenta)
|
||||
End If
|
||||
|
||||
PnlContado.Visible = False
|
||||
@@ -517,6 +557,113 @@ Partial Class Ventas_PVCobranza
|
||||
|
||||
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
|
||||
|
||||
Dim DtRemisiones As New DataTable
|
||||
DtRemisiones.Columns.Add(New DataColumn("CveVenta", GetType(Integer)))
|
||||
DtRemisiones.Columns.Add(New DataColumn("SerieFolio", GetType(String)))
|
||||
|
||||
DtRemisiones.Rows.Add({VentaRemision.CveVenta, VentaRemision.SerieFolio})
|
||||
|
||||
Dim RemisionesLista As New List(Of Integer)
|
||||
RemisionesLista.Add(VentaRemision.CveVenta)
|
||||
|
||||
Dim DtRemisionesPS As New DataTable()
|
||||
Dim DtPagosFacturaGlobal As New DataTable()
|
||||
|
||||
If ObjClientes.GetVentasRemisionesTotales(VentaRemision.CveCliente, VentaRemision.CveVenta.ToString(), 1) Then
|
||||
DtRemisionesPS = ObjClientes.DtResultados.Copy()
|
||||
End If
|
||||
|
||||
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, VentaRemision.CveSubProyecto, VentaRemision.CveCliente, VentaRemision.CveMoneda, "Ing")
|
||||
|
||||
ObjFactura.RemisionesLista = RemisionesLista
|
||||
ObjFactura.DtRemisionesPS = DtRemisionesPS
|
||||
ObjFactura.DtRemisiones = DtRemisiones
|
||||
|
||||
For Each Dr As DataRow In ObjFactura.DtRemisionesPS.Rows
|
||||
ObjFactura.AgregarPS(Dr("CvePS").ToString().ToEntero(), Dr("Cantidad").ToString().ToDecimal(), Dr("PU").ToString().ToDecimal(), Dr("Descuento").ToString().ToDecimal, Dr("Obs").ToString(), CveUM:=Dr("CveUM").ToString().ToEntero(),
|
||||
CveProyecto:=Dr("CveProyecto").ToString().ToEntero(), CveSubProyecto:=Dr("CveSubProyecto").ToString().ToEntero(), CveVentaDetallePadre:=Dr("CveVentaDetalle").ToString().ToEntero(), CveVentaDetalleRemision:=Dr("CveVentaDetalle").ToString().ToEntero(),
|
||||
PorcentajeIVA:=Dr("PorcentajeIVA").ToString().ToDecimal())
|
||||
Next
|
||||
|
||||
ObjFactura.GenerarSalidaAlmacen = True
|
||||
ObjFactura.DtInventario = ObjFactura.DtDetalle.FiltraParametros("CveTipoPS = 2").Copy()
|
||||
ObjFactura.CveAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 1 AND CveSubProyecto = {VentaRemision.CveSubProyecto}").ToString().ToEntero()
|
||||
|
||||
ObjFactura.CalculaTotales()
|
||||
ObjFactura.PreparaTimbre()
|
||||
|
||||
Dim SbAlert As New StringBuilder()
|
||||
|
||||
Try
|
||||
Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta")
|
||||
Retorno.Factura = ObjFactura
|
||||
|
||||
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 factura")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
SbAlert.Append("Ocurrió un error al generar el documento")
|
||||
GuardaLog(ex.ToString())
|
||||
End Try
|
||||
|
||||
If Retorno IsNot Nothing AndAlso Retorno.Mensajes IsNot Nothing AndAlso Retorno.Mensajes.Count > 0 Then
|
||||
Retorno.Mensajes.Clear()
|
||||
Retorno.Mensajes.Add(SbAlert.ToString())
|
||||
|
||||
If Not Retorno.TieneError Then
|
||||
'CONVERTIR LA REMISION EN OBJETO DE FACTURA DE INGRESO, PARA HACER EL PAGO EN LA FACTURA
|
||||
VentaRemision = Nothing
|
||||
|
||||
If ObjVentas.GetVenta(Retorno.CveVenta, UsuarioActual.CveEmpresa) Then
|
||||
Dim DbRowVenta = ObjVentas.DtResultados.Copy().FiltroPrimero("")
|
||||
|
||||
If DbRowVenta IsNot Nothing Then
|
||||
Dim VentaActual As New Venta(UsuarioActual)
|
||||
VentaActual.CveVenta = Retorno.CveVenta
|
||||
VentaActual.TipoDocto = DbRowVenta("TipoDocto").ToString
|
||||
VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate
|
||||
VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero
|
||||
VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero
|
||||
VentaActual.SerieFolio = DbRowVenta("SerieFolio").ToString
|
||||
VentaActual.ClienteNombre = DbRowVenta("ClienteNombre").ToString
|
||||
VentaActual.TC = DbRowVenta("TipoCambio").ToString.ToDecimal
|
||||
VentaActual.Total = DbRowVenta("Total").ToString.ToDecimal
|
||||
VentaActual.IVA = DbRowVenta("IVA").ToString.ToDecimal
|
||||
VentaActual.IEPS = DbRowVenta("IEPS").ToString.ToDecimal
|
||||
VentaActual.RetIVA = DbRowVenta("RetIVA").ToString.ToDecimal
|
||||
VentaActual.RetISR = DbRowVenta("RetISR").ToString.ToDecimal
|
||||
|
||||
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
|
||||
VentaActual.UsuarioActual = UsuarioActual
|
||||
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
|
||||
|
||||
VentaRemision = VentaActual
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
Retorno = New Modelos.Factura.MMensajeFactura()
|
||||
Retorno.TieneError = True
|
||||
If SbAlert.Length = 0 Then
|
||||
SbAlert.Append("Ocurrió un error al generar la factura")
|
||||
End If
|
||||
Retorno.Mensajes.Add(SbAlert.ToString())
|
||||
End If
|
||||
|
||||
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) As String
|
||||
Dim Retorno As String = ""
|
||||
Dim CveIEPago As Integer = 0
|
||||
@@ -761,17 +908,25 @@ Partial Class Ventas_PVCobranza
|
||||
|
||||
Dim ExistePDF As Boolean = False
|
||||
Dim ArchivoPDF As String = ""
|
||||
|
||||
Dim AplicaTicket As Boolean = ObjFactura.CveEmpresa.Contiene(190, 192)
|
||||
|
||||
If ObjFactura.TipoDocto = "Ing" Then
|
||||
ArchivoPDF = String.Format("{0}/PDF/{1}/{2}_Ticket.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
||||
If AplicaTicket Then
|
||||
ArchivoPDF = String.Format("{0}/PDF/{1}/{2}_Ticket.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
||||
Else
|
||||
ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
||||
End If
|
||||
Else
|
||||
ArchivoPDF = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
|
||||
End If
|
||||
|
||||
If File.Exists(ArchivoPDF) AndAlso ObjFactura.TipoDocto = "Rem" Then
|
||||
ExistePDF = True
|
||||
Else
|
||||
'REGENERAR EL PDF
|
||||
Try
|
||||
GenerarPDFVenta(CveVenta, AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False, EsTicket:=True)
|
||||
GenerarPDFVenta(CveVenta, AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False, EsTicket:=AplicaTicket)
|
||||
If File.Exists(ArchivoPDF) Then
|
||||
ExistePDF = True
|
||||
End If
|
||||
|
||||
@@ -631,10 +631,10 @@
|
||||
<asp:TextBox ID="TxtFolioRemision" runat="server" Style="width: 130px" MaxLength="20" Enabled="false"></asp:TextBox>
|
||||
</td>
|
||||
<td runat="server" id="Td10" >
|
||||
|
||||
<b>Tipo de Venta:</b>
|
||||
</td>
|
||||
<td runat="server">
|
||||
|
||||
<asp:Label runat="server" ID="LblTipoVenta"></asp:Label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -5072,7 +5072,7 @@ Partial Class Ventas
|
||||
' End If
|
||||
'End If
|
||||
'si utiliza cortes, y cajas, no permitir cancelar de días anteriores
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso DbRowVenta("Fecha").ToString.ToDate.ToShortDateString.ToDate < Now.ToShortDateString.ToDate Then
|
||||
If UsuarioActual.CveRol <> 1 AndAlso UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso DbRowVenta("Fecha").ToString.ToDate.ToShortDateString.ToDate < Now.ToShortDateString.ToDate Then
|
||||
LbCancelarDocumento.Visible = False
|
||||
End If
|
||||
End If
|
||||
@@ -6173,6 +6173,10 @@ Partial Class Ventas
|
||||
TxtPaciente.Enabled = False
|
||||
TxtEpisodio.Enabled = False
|
||||
|
||||
TrVentasMedicas4.Visible = True
|
||||
TxtFolioRemision.Text = DbRowVenta("Alfa1").ToString
|
||||
|
||||
LblTipoVenta.Text = DbRowVenta("TipoVenta").ToString
|
||||
|
||||
If DbRowVenta("FechaParaSurtir").ToString().ToDate() > DateTime.MinValue Then
|
||||
TrVentasMedicas2.Visible = True
|
||||
@@ -6181,12 +6185,9 @@ Partial Class Ventas
|
||||
|
||||
TxtFechaOS.Text = DbRowVenta("FechaParaSurtir").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm").Replace(" ", "T")
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If DdlTipoDocto.SelectedValue.Contiene("Ing", "Rem") Then
|
||||
TrVentasMedicas4.Visible = True
|
||||
TxtFolioRemision.Text = DbRowVenta("Alfa1").ToString
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Using
|
||||
@@ -8612,6 +8613,9 @@ Partial Class Ventas
|
||||
'If UsuarioActual.CveEmpresa = 119 Then
|
||||
' e.Row.FCTextBox("TxtDescuento").Enabled = False
|
||||
'End If
|
||||
|
||||
|
||||
|
||||
Else
|
||||
'MODO NORMAL
|
||||
|
||||
@@ -8760,11 +8764,13 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
If EsVentaMedica Then
|
||||
|
||||
GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = False
|
||||
|
||||
If DdlTipoComprobante.SelectedValue = "Cot" Then
|
||||
If DdlTipoComprobante.SelectedValue = "Cot" Or RBLTipoVenta.SelectedValue.ToEntero = 1 Then
|
||||
GvPS.Rows(e.NewEditIndex).FCTextBox("TxtPrecio").Enabled = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If CveCicloComercial > 0 Then
|
||||
@@ -17676,7 +17682,7 @@ Partial Class Ventas
|
||||
|
||||
If EsVentaMedica Then
|
||||
TxtPrecio.Enabled = False
|
||||
If UsuarioActual.CveUsuario = 3986 Then
|
||||
If UsuarioActual.CveUsuario = 3986 Or RBLTipoVenta.SelectedValue.ToEntero = 1 Then
|
||||
TxtPrecio.Enabled = True
|
||||
End If
|
||||
|
||||
@@ -22799,8 +22805,9 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
TxtAtencionA.Enabled = True
|
||||
|
||||
|
||||
UpCliente.Update()
|
||||
UPPVentas.Update()
|
||||
UpPS.Update()
|
||||
UpCliente.Update()
|
||||
@@ -23473,8 +23480,8 @@ Partial Class Ventas
|
||||
' DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND (CveTipoCuenta <> 1 OR TieneTerminal = 1)", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero())))
|
||||
'End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
|
||||
DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0}", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero())))
|
||||
If UsuarioActual.Empresa.Funcionalidad(109) = "1" OrElse UsuarioActual.CveEmpresa = 195 Then
|
||||
DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero())))
|
||||
Else
|
||||
DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero())))
|
||||
End If
|
||||
@@ -25595,7 +25602,13 @@ Partial Class Ventas
|
||||
ChkDevAlm.Checked = True
|
||||
End If
|
||||
|
||||
resp = ObjFacturaCancelacion.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar, CveMotivoCancelacion:=DdlMotivoCancelacion.SelectedValue.ToEntero(), Motivo:=TxtMotivoCancelacion.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion)
|
||||
Dim AplicaCancelacionConPagos As Boolean = False
|
||||
|
||||
If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso ObjFactura.TipoDocto.Contiene("Ing", "Rem") AndAlso Not EsRefacturacion AndAlso ObjFactura.Pagado > 0 Then
|
||||
AplicaCancelacionConPagos = True
|
||||
End If
|
||||
|
||||
resp = ObjFacturaCancelacion.CancelarFactura(ChkDevAlm.Checked, ListaRemisionesCancelar, CveMotivoCancelacion:=DdlMotivoCancelacion.SelectedValue.ToEntero(), Motivo:=TxtMotivoCancelacion.Text.Trim(), CveEstadoCancelacion:=Me.CveEstadoCancelacion, AplicaCancelacionConPagos:=AplicaCancelacionConPagos)
|
||||
strMensaje.Append(resp.Mensaje)
|
||||
Dim DtBonificaciones As DataTable = Nothing
|
||||
|
||||
@@ -37779,6 +37792,10 @@ Partial Class Ventas
|
||||
AsignaAlmacenWS()
|
||||
'CargaPS(-1, DdlPS)
|
||||
End If
|
||||
If RBLTipoVenta.SelectedValue.Contiene("1") Then
|
||||
TxtPrecio.Enabled = True
|
||||
UpPS.Update()
|
||||
End If
|
||||
|
||||
RegistraScript("$('#DvModalTipoVenta').modal('hide');")
|
||||
UpCliente.Update()
|
||||
|
||||
Reference in New Issue
Block a user