From 717d5f0a8d0a0009335f2d4c9296997d1f7bfec2 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 26 Feb 2024 16:37:41 -0700 Subject: [PATCH] Saldos iniciales Compras detalles --- General/SaldosIniciales.aspx.vb | 67 ++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index 823a7ced7..618cb935f 100644 --- a/General/SaldosIniciales.aspx.vb +++ b/General/SaldosIniciales.aspx.vb @@ -225,7 +225,7 @@ Partial Class General_SaldosIniciales - ElseIf RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "4" Or RblFormato.SelectedValue = "17" Or Or RblFormato.SelectedValue = "18" Then + ElseIf RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "4" Or RblFormato.SelectedValue = "17" Or RblFormato.SelectedValue = "18" Then If Not dt.Columns(0).ColumnName = "Sucursal" Then Alert("El nombre de la primera columna debe ser 'Sucursal'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub @@ -1474,7 +1474,7 @@ Partial Class General_SaldosIniciales 'P R O V E E D O R E S - F A C T U R A S - ElseIf RblFormato.SelectedValue = "3" Then + ElseIf RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "18" Then #Region "P R O V E E D O R E S - F A C T U R A S" @@ -1499,6 +1499,9 @@ Partial Class General_SaldosIniciales Dim CveClasificacion As Integer = drr("CveClasificacion").ToString().ToEntero() Dim dtsubp As DataTable = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) + + + Dim CountRow As Integer = 1 For Each Row As DataRow In dt.FiltraParametros("RFC <> ''").Rows Dim Sucursal As String = dtsubp.FiltroPrimeroValor("CveSubProyecto", $"SubProyecto = '{Row("Sucursal").ToString()}'") RFC = Row("RFC").ToString().Trim @@ -1559,6 +1562,45 @@ Partial Class General_SaldosIniciales TipoCambio = GlobalTipoCambio(Fecha).ToString End If + + Dim IEPSDetalle As Decimal = 0 + Dim CantidadDetalle As Decimal = 0 + Dim PUDetalle As Decimal = 0 + Dim IVADetalle As Decimal = 0 + + If RblFormato.SelectedValue = "18" Then + + Dim CodigoDetalle As String = Row("Codigo").ToString + If CodigoDetalle.Trim.Length > 0 Then + Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'") + + If DrDetalles IsNot Nothing Then + CvePS = DrDetalles("CvePS").ToString().ToEntero() + CveUnidadMedida = DrDetalles("CveUnidadMedida").ToString().ToEntero() + CveClasificacion = DrDetalles("CveClasificacion").ToString().ToEntero() + Else + Alert($"El código del producto no se encontro, error en registro {CountRow}") + ErrorCompras = True + End If + + Else + Alert($"El código es requerido, error en registro {CountRow}") + ErrorCompras = True + End If + + + IEPSDetalle = Row("IEPS").ToString.ToDecimal + CantidadDetalle = Row("Cantidad").ToString.ToDecimal + PUDetalle = Row("PU").ToString.ToDecimal + IVADetalle = Row("IVA").ToString.ToDecimal + + If CantidadDetalle = 0 Then + Alert($"No se especifico la cantidad, error en registro {CountRow}") + ErrorCompras = True + End If + + End If + 'PrePóliza Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Compras/SaldoInicial", 1, Total, Total, CveMoneda, Fecha, String.Format("{0}-{1}", Serie, Folio), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) If Not CvePrePoliza > 0 Then @@ -1578,10 +1620,24 @@ Partial Class General_SaldosIniciales CveCompra = ObjCompras.CveCompra 'Compra Detalle - If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, 1, SubTotal, SubTotal * PorcentajeIVA, SubTotal, 0, "Carga Inicial", -1, IVAPorcentaje:=PorcentajeIVA, RetIVAPorcentaje:=RetIVAPorcentaje, RetISRPorcentaje:=RetISRPorcentaje) Then - ErrorCompras = True - Exit For + If RblFormato.SelectedValue = "18" Then + + Dim TotalDetalles As Decimal = SubTotal + If PUDetalle > 0 Then + TotalDetalles = (CantidadDetalle * PUDetalle) + IVA - RetIVA - RetISR + IEPSDetalle + End If + + If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, CantidadDetalle, PUDetalle, (CantidadDetalle * PUDetalle) * PorcentajeIVA, TotalDetalles, 0, "Carga Inicial", -1, IVAPorcentaje:=PorcentajeIVA, RetIVAPorcentaje:=RetIVAPorcentaje, RetISRPorcentaje:=RetISRPorcentaje, IEPSPS:=IEPSDetalle) Then + ErrorCompras = True + Exit For + End If + Else + If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, 1, SubTotal, SubTotal * PorcentajeIVA, SubTotal, 0, "Carga Inicial", -1, IVAPorcentaje:=PorcentajeIVA, RetIVAPorcentaje:=RetIVAPorcentaje, RetISRPorcentaje:=RetISRPorcentaje) Then + ErrorCompras = True + Exit For + End If End If + If ImpuestosLocales > 0 Then 'se agrega como parte de la partida, sin iva. If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, CveSubProyecto, -1, 0, 1, ImpuestosLocales, ImpuestosLocales, ImpuestosLocales, 0, "Carga Inicial", -1, IVAPorcentaje:=0, RetIVAPorcentaje:=0, RetISRPorcentaje:=0) Then ErrorCompras = True @@ -1610,6 +1666,7 @@ Partial Class General_SaldosIniciales End If Encontrados = Encontrados + 1 + CountRow = CountRow + 1 Next Catch ex As Exception