From 909036cb129185aeebfc51c50b009f4224e25f6d Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Sun, 20 Oct 2024 17:21:06 -0700 Subject: [PATCH 1/5] --GDiaz: Generacion de NC en cobro por caja --- App_Code/Modelos.vb | 80 ++++-- Ventas/PVCobranza.aspx | 317 ++++++++++++++++++++++-- Ventas/PVCobranza.aspx.vb | 501 +++++++++++++++++++++++++++++++++++++- 3 files changed, 845 insertions(+), 53 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index a37c2505c..78f1bf2e6 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -3505,6 +3505,39 @@ Namespace Modelos Pago.Referencia = Concepto ErrorPrepoliza = ClsPaginas.AplicaPrePolizaPagoVenta(ventaRef, Pago, ObjFactura.CvePrePoliza, ObjConta) + + If Not ErrorPrepoliza AndAlso ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.EsNCAmortizacion AndAlso ObjFactura.TipoDocto.Contiene("Egs") AndAlso ObjFactura.DtAnticiposAplicados IsNot Nothing Then + + For Each row2 As DataRow In ObjFactura.DtAnticiposAplicados.Rows + If row2("CveConceptoContable").ToString().ToEntero() = 3 Then + CveIEAnticipo = row2("CveIE").ToString().ToEntero() + + importeMovimiento = row2("Importe").ToString().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("CveMoneda").ToString().ToEntero() + + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + + If ObjFactura.CveTipoAmortizacionAnticipo = 2 Then + Dim DescuentosAnticipos As Decimal = row2("Descuentos").ToString().ToDecimal + ImporteAnticipo = ImporteAnticipo / (row2("TotalAnticipo").ToString().ToDecimal - DescuentosAnticipos) * row2("SubTotalAnticipo").ToString().ToDecimal + ImporteAnticipo = ImporteAnticipo.RoundSQL(2) + End If + + Dim Importe11MX As Decimal = ImporteAnticipo + CveSubProyectoContabilizar = CveSubProyectoVenta + + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, False, Importe11MX, Importe11MX, 11, Referencia, Concepto, CveVenta:=row2("CveVenta").ToString().ToEntero(), CveVentaAmortizacion:=ObjFactura.CveVenta, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + Exit For + End If + End If + End If + Next + + End If Next If ObjConta.ValidacionesPrePoliza(ObjFactura.CvePrePoliza, UsuarioActual, Opcion:=5) Then @@ -3517,6 +3550,9 @@ Namespace Modelos ' Dim DtTest = ObjConta.DtResultados 'End If End If + + importeMovimiento = 0 + importeMX = 0 End If If ErrorPrepoliza Then @@ -3667,30 +3703,31 @@ Namespace Modelos ' cuando es amortización de nota de crédito, y es la nc ' cuando es amortización por descuento, y es el ingreso ' cuando es amortización en cero - If (ObjFactura.CveTipoAmortizacionAnticipo = 2 AndAlso ObjFactura.TipoDocto.Contiene("Egs") OrElse - ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse - ObjFactura.CveTipoAmortizacionAnticipo = 3) Then - For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows - If row2("CveConceptoContable").ToString().ToEntero = 11 Then - CveIEAnticipo = -1 - importeMovimiento = row2("Importe").ToString().ToDecimal() - If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" + If (ObjFactura.CveTipoAmortizacionAnticipo = 1 AndAlso ObjFactura.TipoDocto.Contiene("Ing") OrElse ObjFactura.CveTipoAmortizacionAnticipo = 3) Then + If DtAnticipos IsNot Nothing Then + For Each row2 As DataRow In ObjFactura.DtAnticipos.Rows + If row2("CveConceptoContable").ToString().ToEntero = 11 Then + CveIEAnticipo = -1 + importeMovimiento = row2("Importe").ToString().ToDecimal() + If tipoCambio > 1 Then Concepto += $" TC:{tipoCambio} ${importeMovimiento.FormatoNumero(2)}" - CveSubProyectoContabilizar = CveSubProyectoVenta + CveSubProyectoContabilizar = CveSubProyectoVenta - If importeMovimiento <> 0 Then - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, ConceptoContable, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, - CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, - ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), - CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - Exit For - Else - ObjFactura.SeGuardoPrePoliza = True + If importeMovimiento <> 0 Then + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, importeMovimiento * tipoCambio, ConceptoContable, Referencia, Concepto, CveVenta:=ObjFactura.CveVenta, + CveVentaAmortizacion:=row2("CveVenta").ToString.ToEntero, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEAnticipo, + ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), + CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + Exit For + Else + ObjFactura.SeGuardoPrePoliza = True + End If End If End If - End If - Next + Next + End If + End If End If @@ -6697,7 +6734,7 @@ Namespace Modelos If Not ObjVentas.UpdateEstatusOCRelacionada(ObjFactura.CveVenta, CveEstatusCancelacion, ObjFactura.CveEmpresa) Then ErrorCancelar = True MensajeError = "Ocurrió un error al cancelar la orden de servicio" - else + Else End If End If End If @@ -7601,6 +7638,7 @@ Namespace Modelos Public Property DtDocumentosRelacionados As Data.DataTable Public Property DtNCVinculadas As Data.DataTable Public Property DtAnticipos As Data.DataTable + Public Property DtAnticiposAplicados As Data.DataTable Public Property DtPromociones As Data.DataTable Public Property DtImpuestosLocales As Data.DataTable Public Property DtPagos As Data.DataTable diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index bd66a876e..56b7a9975 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -411,6 +411,10 @@
+
+ +
+ @@ -524,6 +528,24 @@ +
+
+
+ +
+
+ $ + + +
+
+ + +
+
+
+
@@ -563,21 +585,21 @@
- +
$
- +
$
- +
$ @@ -1008,7 +1030,6 @@ - ") @@ -1447,7 +1453,7 @@ Partial Class Sistemas_UsuarioDetalle SBBody.Append("
") SBBody.Append("Nota Favor de NO responder este correo. ") SBBody.Append("


") - SBBody.AppendFormat("", UrlSitio) + SBBody.AppendFormat("", UrlsitioUrlActual) SBBody.Append("
") SBBody.Append("
") 'Termino Cuerpo del correo @@ -1458,6 +1464,27 @@ Partial Class Sistemas_UsuarioDetalle OnError("Ocurrió error al mandar MAIL", ex) End Try End Sub + + + Public Function ObtenerUrlCompleta() As String + + Dim Solicitud As HttpRequest = HttpContext.Current.Request + Dim url As String = Solicitud.Url.Scheme & "://" & Solicitud.Url.Host + + If (Solicitud.Url.Port <> 80 AndAlso Solicitud.Url.Port <> 443) Then + url &= ":" & Solicitud.Url.Port + End If + + + url &= Solicitud.ApplicationPath + + If Not url.EndsWith("/") Then + url &= "/" + End If + + Return url + End Function + #End Region From 4a7854492904668939e54e33d2376b01485b474d Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 21 Oct 2024 11:48:27 -0700 Subject: [PATCH 3/5] --FIX generacion de NC en cobranza --- App_Code/Modelos.vb | 8 +- Ventas/PVCobranza.aspx | 7 +- Ventas/PVCobranza.aspx.vb | 223 +++++++++++++++++++++++++------------- 3 files changed, 158 insertions(+), 80 deletions(-) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 78f1bf2e6..701782670 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -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("
La {0}: {1} se generó correctamente.

", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio)) + If MostrarURL Then + MensajeAlert.AppendFormat("
La {0}: {1} se generó correctamente.

", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio, Me.CveVenta) + Else + MensajeAlert.AppendFormat(String.Format("
La {0}: {1} se generó correctamente.

", If(Me.TipoDocumento = "Ingresos", "Factura", Me.TipoDocumento), Me.SerieFolio)) + End If ' DESCARGA XML - SI SE TIMBRA MANDA CORREO CON FACTURA If SeTimbro Then diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index 56b7a9975..6e34641e4 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -535,8 +535,8 @@
$ - - + +