Ferretera. Impresion con copia, facturacion de remision con pago en ventas.aspx

This commit is contained in:
2024-03-22 00:53:11 -07:00
parent ac5b03218d
commit 86e74272f5
5 changed files with 171 additions and 24 deletions

View File

@@ -4100,7 +4100,7 @@ Namespace Modelos
'CANCELACION DE PAGOS DE REMISIONES 'CANCELACION DE PAGOS DE REMISIONES
If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then
For Each DrPago As DataRow In DtPagosFacturaGlobal.Rows For Each DrPago As DataRow In ObjFactura.DtPagosFacturaGlobal.Rows
Dim ventaRef As ClsPaginas.Venta = Nothing Dim ventaRef As ClsPaginas.Venta = Nothing
@@ -4164,7 +4164,7 @@ Namespace Modelos
Dim VentaActual As New ClsPaginas.Venta(ObjFactura, UsuarioActual) Dim VentaActual As New ClsPaginas.Venta(ObjFactura, UsuarioActual)
For Each DrPago As DataRow In DtPagosFacturaGlobal.Rows For Each DrPago As DataRow In ObjFactura.DtPagosFacturaGlobal.Rows
Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal() Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal()
Dim Pago As New ClsPaginas.VentaPago Dim Pago As New ClsPaginas.VentaPago

View File

@@ -813,6 +813,11 @@
function impresionDirecta(urlPDF) { function impresionDirecta(urlPDF) {
printJS({ printable: urlPDF, type: 'pdf', showModal: true }); printJS({ printable: urlPDF, type: 'pdf', showModal: true });
} }
function impresionBase64(pdfBase64) {
printJS({ printable: pdfBase64, type: 'pdf', showModal: true, base64: true });
}
function CalculaTotalPagoContado() { function CalculaTotalPagoContado() {
debugger; debugger;
var totalEfectivo = ToDouble($get("TxtImporteEfectivo").value); var totalEfectivo = ToDouble($get("TxtImporteEfectivo").value);

View File

@@ -2,6 +2,7 @@
Option Strict On Option Strict On
Imports System.Data Imports System.Data
Imports System.IO
Imports Extensiones Imports Extensiones
Partial Class Ventas_PVCobranza Partial Class Ventas_PVCobranza
@@ -543,13 +544,13 @@ Partial Class Ventas_PVCobranza
Dim ExistePDF As Boolean = False Dim ExistePDF As Boolean = False
Dim ArchivoPDF As String = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) Dim ArchivoPDF As String = String.Format("{0}/PDF/{1}/{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio)
If ObjFactura.TipoDocto = "Rem" AndAlso System.IO.File.Exists(ArchivoPDF) Then If File.Exists(ArchivoPDF) Then
ExistePDF = True ExistePDF = True
Else Else
'REGENERAR EL PDF 'REGENERAR EL PDF
Try Try
GenerarPDFVenta(CveVenta, AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False, EsTicket:=True) GenerarPDFVenta(CveVenta, AplicaPagare:="1", GuardarPDF:=True, RegenerarPDF:=True, DescargarArchivo:=False)
If System.IO.File.Exists(ArchivoPDF) Then If File.Exists(ArchivoPDF) Then
ExistePDF = True ExistePDF = True
End If End If
Catch ex As Exception Catch ex As Exception
@@ -558,8 +559,24 @@ Partial Class Ventas_PVCobranza
End If End If
If ExistePDF Then If ExistePDF Then
Dim urlPDF As String = $"/Ashx/SIGDesc.ashx?metodo=descargarPDFVenta&CveVenta={CveVenta}" Dim pdf64 As String = ""
RegistraScript($"impresionDirecta('{urlPDF}');", "Imprimir") 'DUPLICA EL PDF
Using ms As New MemoryStream
Using pdfdoc As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfWriter(ms))
pdfdoc.InitializeOutlines()
Dim reporteByte As New MemoryStream(System.IO.File.ReadAllBytes(ArchivoPDF))
Dim docPDF As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfReader(reporteByte))
docPDF.CopyPagesTo(1, docPDF.GetNumberOfPages(), pdfdoc)
docPDF.CopyPagesTo(1, docPDF.GetNumberOfPages(), pdfdoc)
docPDF.Close()
pdfdoc.Close()
End Using
pdf64 = Convert.ToBase64String(ms.ToArray())
End Using
RegistraScript($"impresionBase64('{pdf64}');", "Imprimir")
Else Else
Alert("No se pudo imprimir el pdf directamente. favor de descargar manualmente el pdf.", TipoMensaje.MsgAdvertencia) Alert("No se pudo imprimir el pdf directamente. favor de descargar manualmente el pdf.", TipoMensaje.MsgAdvertencia)
End If End If

View File

@@ -8878,6 +8878,10 @@
printJS({printable:urlPDF, type:'pdf', showModal:true}); printJS({printable:urlPDF, type:'pdf', showModal:true});
} }
function impresionBase64(pdfBase64) {
printJS({printable:pdfBase64, type:'pdf', showModal:true, base64: true});
}
function abrirDdlPS(){ function abrirDdlPS(){
$(document).ready(function() { $(document).ready(function() {
$('#C_Tab_TabGenerales_DdlPS > select').select2('open').next().find(':input.select2-search__field').focus(); $('#C_Tab_TabGenerales_DdlPS > select').select2('open').next().find(':input.select2-search__field').focus();

View File

@@ -12445,6 +12445,36 @@ Partial Class Ventas
ObjFactura.DtMercancias = DtMercancias ObjFactura.DtMercancias = DtMercancias
ObjFactura.DtImpuestosLocales = TmpDTImpuestos ObjFactura.DtImpuestosLocales = TmpDTImpuestos
'TRASPASAR PAGOS DE REMISIONES A LA FACTURA NUEVA
If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso ObjFactura.TipoDocto = "Ing" Then
Dim DtRemisionesPagos As DataTable = Nothing
If Me.CveVenta > 0 AndAlso TipoDoctoViejo = "Rem" Then
Dim ObjClientes As New ClsClientes
If ObjClientes.GetVentasRemisionesPagos(CveCliente, Me.CveVenta.ToString()) Then
DtRemisionesPagos = ObjClientes.DtResultados.Copy()
End If
ObjClientes.Dispose()
ElseIf Me.RemisionesLista IsNot Nothing AndAlso Me.RemisionesLista.Count > 0 Then
Dim sb As New StringBuilder
For Each CveRemision As Integer In RemisionesLista
sb.Append($"{CveRemision},")
Next
sb.Remove(sb.Length - 1, 1)
Dim ObjClientes As New ClsClientes
If ObjClientes.GetVentasRemisionesPagos(CveCliente, sb.ToString()) Then
DtRemisionesPagos = ObjClientes.DtResultados.Copy()
End If
ObjClientes.Dispose()
End If
If DtRemisionesPagos IsNot Nothing Then
ObjFactura.DtPagosFacturaGlobal = DtRemisionesPagos
End If
End If
End Sub End Sub
Private Sub CreaObjetosVentaDevolucion() Private Sub CreaObjetosVentaDevolucion()
@@ -15438,6 +15468,49 @@ Partial Class Ventas
ErrorPrepoliza = True ErrorPrepoliza = True
ErrorList.Add("No se pueden facturar las remisiones, con ese tipo de comprobante seleccionado") ErrorList.Add("No se pueden facturar las remisiones, con ese tipo de comprobante seleccionado")
Else Else
'CANCELACION DE PAGOS DE REMISIONES
If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then
For Each DrPago As DataRow In ObjFactura.DtPagosFacturaGlobal.Rows
Dim ventaRef As ClsPaginas.Venta = Nothing
Using ObjFacturaRef As New Modelos.Factura(UsuarioActual, DrPago("CveVenta").ToString().ToEntero(), UsuarioActual.CveEmpresa, CargaDTDetalle:=False, VerificaAlmacen:=False, CargaDatosCliente:=False, CargaDatosRelacionados:=False)
ventaRef = New ClsPaginas.Venta(ObjFacturaRef, UsuarioActual)
End Using
If ventaRef IsNot Nothing Then
Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal() * -1
Dim Pago As New ClsPaginas.VentaPago
Pago.Fecha = Now
Pago.FechaDocumentoRelacionado = DrPago("FechaDocumento").ToString().ToDate
Pago.ImportePagoVenta = Importe
Pago.ImportePago = Importe
Pago.CveIE = DrPago("CveIE").ToString().ToEntero()
Pago.CveMonedaPago = DrPago("CveMoneda").ToString().ToEntero()
Pago.TCPago = DrPago("TipoCambio").ToString().ToDecimal()
Pago.AplicaTraslado = False
Pago.Referencia = DrPago("Folio").ToString()
Pago.CveVentaAmortizacion = -1
If DrPago("TipoPago").ToString() = "NC" Then
Pago.TipoPago = "NC"
Else
Pago.TipoPago = "B"
End If
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=False)
Else
ErrorPrepoliza = True
End If
If ErrorPrepoliza Then
Exit For
End If
Next
End If
For Each CveRemision As Integer In RemisionesLista For Each CveRemision As Integer In RemisionesLista
If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then If Not ObjConta.TraspasarSaldosRemision(CveRemision, ObjFactura.CvePrePoliza, ObjFactura.CveVenta) Then
@@ -15463,6 +15536,41 @@ Partial Class Ventas
ErrorPrepoliza = True ErrorPrepoliza = True
End If End If
Next Next
'TRASPASO DE PAGOS DE REMISIONES A FACTURA GLOBAL
If ObjFactura.DtPagosFacturaGlobal IsNot Nothing Then
Dim VentaActual As New ClsPaginas.Venta(ObjFactura, UsuarioActual)
For Each DrPago As DataRow In ObjFactura.DtPagosFacturaGlobal.Rows
Dim Importe As Decimal = DrPago("Importe").ToString().ToDecimal()
Dim Pago As New ClsPaginas.VentaPago
Pago.Fecha = Now
Pago.FechaDocumentoRelacionado = DrPago("FechaDocumento").ToString().ToDate
Pago.ImportePagoVenta = Importe
Pago.ImportePago = Importe
Pago.CveIE = DrPago("CveIE").ToString().ToEntero()
Pago.CveMonedaPago = DrPago("CveMoneda").ToString().ToEntero()
Pago.TCPago = DrPago("TipoCambio").ToString().ToDecimal()
Pago.AplicaTraslado = False
Pago.Referencia = DrPago("Folio").ToString()
Pago.CveVentaAmortizacion = DrPago("CveVenta").ToString().ToEntero()
If DrPago("TipoPago").ToString() = "NC" Then
Pago.TipoPago = "NC"
Else
Pago.TipoPago = "B"
End If
ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(VentaActual, Pago, ObjFactura.CvePrePoliza, ObjConta, AplicarConceptoAplicacion:=False)
If ErrorPrepoliza Then
Exit For
End If
Next
End If
End If End If
End If End If
@@ -29095,9 +29203,8 @@ Partial Class Ventas
End If End If
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
If TxtAtencionA.Text.Trim.Length = 0 Then TxtAtencionA.Enabled = True
TxtAtencionA.Enabled = True UpCliente.Update()
End If
End If End If
Catch ex As Exception Catch ex As Exception
@@ -30160,12 +30267,6 @@ Partial Class Ventas
Exit Sub Exit Sub
End If End If
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
If TxtAtencionA.Text.Trim.Length = 0 Then
TxtAtencionA.Enabled = True
End If
End If
AplicaDevolucion = True AplicaDevolucion = True
SaldoVentaDevolucion = HplSaldoAuxiliar.Text.ToDecimal SaldoVentaDevolucion = HplSaldoAuxiliar.Text.ToDecimal
CveVentaDevolucion = CveVenta CveVentaDevolucion = CveVenta
@@ -30238,6 +30339,11 @@ Partial Class Ventas
CargaNC(CveVenta) CargaNC(CveVenta)
CalculaTotalesVenta() CalculaTotalesVenta()
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
TxtAtencionA.Enabled = True
UpCliente.Update()
End If
RegistraScript("$('#DivAplicaDevolucion').modal('hide')") RegistraScript("$('#DivAplicaDevolucion').modal('hide')")
End Sub End Sub
@@ -37534,8 +37640,24 @@ Partial Class Ventas
End If End If
If ExistePDF Then If ExistePDF Then
Dim urlPDF As String = $"/Ashx/SIGDesc.ashx?metodo=descargarPDFVenta&CveVenta={CveVenta}" Dim pdf64 As String = ""
RegistraScript($"impresionDirecta('{urlPDF}');", "Imprimir") 'DUPLICA EL PDF
Using ms As New MemoryStream
Using pdfdoc As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfWriter(ms))
pdfdoc.InitializeOutlines()
Dim reporteByte As New MemoryStream(System.IO.File.ReadAllBytes(ArchivoPDF))
Dim docPDF As New iText.Kernel.Pdf.PdfDocument(New iText.Kernel.Pdf.PdfReader(reporteByte))
docPDF.CopyPagesTo(1, docPDF.GetNumberOfPages(), pdfdoc)
docPDF.CopyPagesTo(1, docPDF.GetNumberOfPages(), pdfdoc)
docPDF.Close()
pdfdoc.Close()
End Using
pdf64 = Convert.ToBase64String(ms.ToArray())
End Using
RegistraScript($"impresionBase64('{pdf64}');", "Imprimir")
Else Else
Alert("No se pudo imprimir el pdf directamente. favor de descargar manualmente el pdf.", TipoMensaje.MsgAdvertencia) Alert("No se pudo imprimir el pdf directamente. favor de descargar manualmente el pdf.", TipoMensaje.MsgAdvertencia)
End If End If
@@ -37734,14 +37856,13 @@ Partial Class Ventas
LimpiaDocumentoDEV() LimpiaDocumentoDEV()
CambiaTipoDocto() CambiaTipoDocto()
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
If TxtAtencionA.Text.Trim.Length = 0 Then
TxtAtencionA.Enabled = True
End If
End If
CalculaTotalesVenta() CalculaTotalesVenta()
If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then
TxtAtencionA.Enabled = True
UpCliente.Update()
End If
UpParametros.Update() UpParametros.Update()
AplicaDevolucion = True AplicaDevolucion = True