From d27e2ee52021c6d88598705c7ac884ac695ce4d8 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Mon, 26 Feb 2024 11:29:41 -0700 Subject: [PATCH 1/3] FERRETERA. --fix de porcentaje de utilidad --- Ventas/Ventas.aspx | 45 +++++++++++++++++++++++++++---------------- Ventas/Ventas.aspx.vb | 8 ++++---- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx index 40122ad0c..ddb128135 100644 --- a/Ventas/Ventas.aspx +++ b/Ventas/Ventas.aspx @@ -604,7 +604,7 @@ Fecha de Cirugia: - + @@ -9795,44 +9795,55 @@ function CalculaDescPS() { if ($get("TxtPorPS").value != "") { - var PorcentajeDescuento = parseFloat($get("TxtPorPS").value); + let PorcentajeDescuento = parseFloat($get("TxtPorPS").value); if (PorcentajeDescuento < 0 || PorcentajeDescuento > 99) { alert("No se puede aplicar ese porcentaje de descuento"); $get("TxtPorPS").value = "0"; + recalcularUtilidad(0); return; } - var ivaPor = parseFloat($get("HdnIVADescPS").value) ; + let ivaPor = parseFloat($get("HdnIVADescPS").value) ; - var subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); + let subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); $get("LblDescPS").innerText = formato_numero(((subTotal * PorcentajeDescuento) / 100), 2, '.', ','); - var descuento = parseFloat($get("LblDescPS").innerText.replace(",", "").replace(",", "")); + let descuento = parseFloat($get("LblDescPS").innerText.replace(",", "").replace(",", "")); $get("LblIVADescPS").innerText = formato_numero(((subTotal - descuento) * ivaPor), 2, '.', ','); - var importeIVA =parseFloat($get("LblIVADescPS").innerText.replace(",", "").replace(",", "")); + let importeIVA =parseFloat($get("LblIVADescPS").innerText.replace(",", "").replace(",", "")); - var Total = (subTotal - descuento) + importeIVA; + let Total = (subTotal - descuento) + importeIVA; $get("LblTotalFinalDescPS").innerText = formato_numero(Total, 2, '.', ','); $get("HdnDescPS").value = descuento; - var totalCompra = parseFloat($get("HdnTotalCompra").value); - if (totalCompra > 0) { - var totalRedondeado = parseFloat($get("LblTotalFinalDescPS").innerText.replace(",", "").replace(",", "")); - var utilidad = ((totalRedondeado - totalCompra) / totalRedondeado) * 100; + recalcularUtilidad(descuento) + } else { + let subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); + $get("LblIVADescPS").innerText = formato_numero((subTotal * ivaPor), 2, '.', ','); + let importeIVA =parseFloat($get("LblIVADescPS").innerText.replace(",", "").replace(",", "")); + let Total = (subTotal) + importeIVA; - $get("LblUtilidadPorcentaje").innerText = formato_numero(utilidad, 2, '.', ','); - } - } - else { - $get("LblTotalFinalDescPS").innerText = "0.00"; + $get("LblTotalFinalDescPS").innerText = formato_numero(Total, 2, '.', ','); $get("LblDescPS").innerText = "0.00"; - $get("LblIVADescPS").innerText = "0.00"; $get("LblUtilidadPorcentaje").innerText = "0.00"; $get("HdnDescPS").innerText = "0.00"; + + recalcularUtilidad(0); + } + } + + function recalcularUtilidad(descuento){ + let totalCompra = parseFloat($get("HdnTotalCompra").value); + if (totalCompra > 0) { + let subTotal = parseFloat($get("LblSubtotalDescPS").innerText.replace(",", "").replace(",", "")); + let subTotal2 = subTotal - descuento; + let utilidad = ((subTotal2 - totalCompra) / subTotal2) * 100; + + $get("LblUtilidadPorcentaje").innerText = formato_numero(utilidad, 2, '.', ','); } } diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 4a634eae8..79b0aff37 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -24047,13 +24047,13 @@ Partial Class Ventas Using ObjPS As New ClsProductosServicios Dim PrecioCompra = ObjPS.GetUltimoPrecioCompra(UsuarioActual.CveEmpresa, GvRow.DataKey("CvePS").ToEntero()) If PrecioCompra > 0 Then - Dim TotalCompra = (PrecioCompra * GvRow.DataKey("Cantidad").ToDouble() * (1 + GvRow.DataKey("IVA").ToDecimal())) - HdnTotalCompra.Value = TotalCompra.ToString() + Dim SubTotalCompra = (PrecioCompra * GvRow.DataKey("Cantidad").ToDouble()) + HdnTotalCompra.Value = SubTotalCompra.ToString() LblPrecioCompra.Text = $"PU Compra: {(PrecioCompra).FormatoNumero(2)}" - Dim TotalRedondeado = GvRow.DataKey("Total").ToDecimal() + GvRow.DataKey("ImporteIVA").ToDecimal() + Dim SubTotal = GvRow.DataKey("Total").ToDecimal() - Dim PorUtilidad = ((TotalRedondeado - TotalCompra) / TotalRedondeado) * 100D + Dim PorUtilidad = ((SubTotal - SubTotalCompra) / SubTotal) * 100D LblUtilidadPorcentaje.Text = PorUtilidad.FormatoNumero(2) End If End Using From dd4ba99ad004182f9eca6d70e042f49be0cccf8e Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 26 Feb 2024 11:56:28 -0700 Subject: [PATCH 2/3] Compras valdiacion base retenciones --- Compras/Compras.aspx.vb | 51 +++++++++++- General/SaldosIniciales.aspx | 2 + General/SaldosIniciales.aspx.vb | 139 ++++++++++++++++++++------------ 3 files changed, 139 insertions(+), 53 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 1b294be84..3053788b3 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -10,6 +10,7 @@ Imports System.Threading.Tasks Imports Newtonsoft.Json Imports Extensiones Imports MoreLinq +Imports ClbNegBICFDv3_3 Partial Class Compras_Compras Inherits ClsPaginas @@ -1341,7 +1342,7 @@ Partial Class Compras_Compras CambiaEjercicioAC() End If UpConsignaciones.Update() - UpINV.Update() + UpInv.Update() 'DdlIVA.Visible = True ' cuando es compra manual 'If UsuarioActual.CveEmpresa = 126 Then ' CargaOrdenCorte() @@ -1735,6 +1736,50 @@ Partial Class Compras_Compras End If End If + + + + Dim SbValRet As New StringBuilder + For Each concepto As XmlNode In nodeconceptos + ' Obtener la descripción del concepto + Dim descripcion As String = ValorXML(concepto, "Descripcion") + Dim importeValue As Decimal = Decimal.Parse(ValorXML(concepto, "Importe")) + + ' Seleccionar el nodo de Impuestos dentro de Concepto, si existe + Dim impuestosNode As XmlNode = concepto.SelectSingleNode("cfdi:Impuestos", namespaces) + + If Not impuestosNode Is Nothing Then + ' Seleccionar los nodos de Retencion dentro de Impuestos + Dim retenciones As XmlNodeList = impuestosNode.SelectNodes("cfdi:Retenciones/cfdi:Retencion", namespaces) + For Each retencion As XmlNode In retenciones + ' Obtener los valores de los atributos Base e Importe + Dim baseValue As Decimal = Decimal.Parse(ValorXML(retencion, "Base")) + Dim impuesto As String = ValorXML(retencion, "Impuesto") + + If impuesto = "001" Then + impuesto = "Retención ISR" + ElseIf impuesto = "002" Then + impuesto = "Retención IVA" + ElseIf impuesto = "003" Then + impuesto = "IEPS" + End If + + + ' Validar si Base coincide con Importe + If baseValue <> importeValue Then + 'SbValRet.Append($"La base e importe de la retención del impuesto {impuesto} no coinciden para {descripcion}. Base: {baseValue.ToString()}, Importe: {importeValue.ToString()}
") + SbValRet.Append($"Producto: {descripcion} La base e importe del impuesto {impuesto} no coincide Base: {baseValue.ToString()}, Importe Producto: {importeValue.ToString()}
") + End If + Next + End If + Next + + If SbValRet.ToString.Trim.Length > 0 Then + Alert(SbValRet.ToString, TipoMensaje.MsgAdvertencia) + End If + + + Else CargaConceptosXML(XMLDoc) End If @@ -20085,6 +20130,10 @@ Partial Class Compras_Compras DdlRefacturacionFacturas.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub + + Protected Sub BtnRecolecciónAplicar_Click(sender As Object, e As EventArgs) + + End Sub End Class diff --git a/General/SaldosIniciales.aspx b/General/SaldosIniciales.aspx index abcd818cb..ca8908565 100644 --- a/General/SaldosIniciales.aspx +++ b/General/SaldosIniciales.aspx @@ -39,6 +39,8 @@ + + diff --git a/General/SaldosIniciales.aspx.vb b/General/SaldosIniciales.aspx.vb index ad5eccb24..823a7ced7 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" Then + ElseIf RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "4" Or RblFormato.SelectedValue = "17" Or 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 @@ -293,54 +293,84 @@ Partial Class General_SaldosIniciales Exit Sub End If - If Not dt.Columns(15).ColumnName = "Folio Fiscal" Then - Alert("El nombre de la decimosexta columna debe ser 'Folio Fiscalo'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(16).ColumnName = "PorcentajeIVA" Then - Alert("El nombre de la decimoséptima columna debe ser 'PorcentajeIVA'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If + If RblFormato.SelectedValue = "3" Or RblFormato.SelectedValue = "18" Then - 'If RblFormato.SelectedValue = "4" Then - ' If Not dt.Columns(15).ColumnName = "ImpuestoLocal" Then - ' Alert("El nombre de la diesciseisava columna debe ser 'ImpuestoLocal'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - - ' If Not dt.Columns(16).ColumnName = "Amort.Ant" Then - ' Alert("El nombre de la diescisieteava columna debe ser 'Amort.Ant'. Favor de corregirlo", TipoMensaje.MsgError) - ' Exit Sub - ' End If - 'End If - - If RblFormato.SelectedValue = "17" Then - - - If Not dt.Columns(17).ColumnName = "Cantidad" Then - Alert("El nombre de la Decimoctava columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError) + If Not dt.Columns(15).ColumnName = "PorcentajeIVA" Then + Alert("El nombre de la quinceava columna debe ser 'PorcentajeIVA'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(18).ColumnName = "PU" Then - Alert("El nombre de la Decimonovena columna debe ser 'PU'. Favor de corregirlo", TipoMensaje.MsgError) + If Not dt.Columns(16).ColumnName = "ImpuestosLocales" Then + Alert("El nombre de la quinceava columna debe ser 'ImpuestosLocales'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(19).ColumnName = "IVA" Then - Alert("El nombre de la Vigésima columna debe ser 'IVA'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If + If RblFormato.SelectedValue = "18" Then + If Not dt.Columns(17).ColumnName = "Cantidad" Then + Alert("El nombre de la Decimoctava columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If - - If Not dt.Columns(20).ColumnName = "IEPS" Then - Alert("El nombre de la Vigésimo primera columna debe ser 'IEPS'. Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub + If Not dt.Columns(18).ColumnName = "Codigo" Then + Alert("El nombre de la Decimonovena columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(19).ColumnName = "PU" Then + Alert("El nombre de la Vigésima columna debe ser 'PU'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(20).ColumnName = "IVADetalle" Then + Alert("El nombre de la Vigésimo primera columna debe ser 'IVADetalle'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(21).ColumnName = "IEPS" Then + Alert("El nombre de la Vigésimo segunda columna debe ser 'IEPS'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If End If End If + + If RblFormato.SelectedValue = "4" Or RblFormato.SelectedValue = "17" Then + If Not dt.Columns(15).ColumnName = "Folio Fiscal" Then + Alert("El nombre de la decimosexta columna debe ser 'Folio Fiscalo'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If Not dt.Columns(16).ColumnName = "PorcentajeIVA" Then + Alert("El nombre de la decimoséptima columna debe ser 'PorcentajeIVA'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If RblFormato.SelectedValue = "17" Then + If Not dt.Columns(17).ColumnName = "Cantidad" Then + Alert("El nombre de la Decimoctava columna debe ser 'Cantidad'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + + If Not dt.Columns(18).ColumnName = "Codigo" Then + Alert("El nombre de la Decimonovena columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(19).ColumnName = "PU" Then + Alert("El nombre de la Vigésima columna debe ser 'PU'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(20).ColumnName = "IVADetalle" Then + Alert("El nombre de la Vigésimo primera columna debe ser 'IVADetalle'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(21).ColumnName = "IEPS" Then + Alert("El nombre de la Vigésimo segunda columna debe ser 'IEPS'. Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + End If + End If + + + ElseIf RblFormato.SelectedValue = "5" Then If Not dt.Columns(0).ColumnName = "Codigo" Then @@ -1688,7 +1718,7 @@ Partial Class General_SaldosIniciales Dim CodigoDetalle As String = Row("Codigo").ToString If CodigoDetalle.Trim.Length > 0 Then - Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = {CodigoDetalle}") + Dim DrDetalles As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimero($"Codigo = '{CodigoDetalle}'") If DrDetalles IsNot Nothing Then CvePS = DrDetalles("CvePS").ToString().ToEntero() @@ -1811,9 +1841,6 @@ Partial Class General_SaldosIniciales - - - Dim ConceptoContable As Integer = 1 Dim ConceptoContablePago As Integer = 2 If TipoDocto = "Egs" Then @@ -1844,6 +1871,11 @@ Partial Class General_SaldosIniciales If RetIVA > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetIVA, RetIVA, 8, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For End If + + 'If RetISR > 0 Then + ' If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, RetISR, RetISR, 9, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=Porce, Contabilizable:=False) Then ErrorVentas = True : Exit For + 'End If + If ImpuestoLocal > 0 Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImpuestoLocal, ImpuestoLocal, 27, Folio.ToString(), String.Format("{0}-{1}", Serie, Folio), CveVenta:=CveVenta, CveCliente:=CveCliente, PorcentajeImpuesto:=PorcentajeIVA, Contabilizable:=False) Then ErrorVentas = True : Exit For End If @@ -2387,7 +2419,7 @@ Partial Class General_SaldosIniciales Dim AlmacenRef As DataTable = GlobalDTAlmacen(UsuarioActual.CveEmpresa) Dim contadorMovimientos As Integer = 0 Dim listadoMovimientos As String = "" - Dim mensajeError As String = "" + Dim mensajeError As New StringBuilder Dim Fecha As DateTime = (TxtFecha.Text).ToDate Try For Each almacenSinRepetir As DataRow In dt.FiltraParametros("Almacen <> ''", DistinctColumns:={"Almacen"}).Rows @@ -2403,6 +2435,7 @@ Partial Class General_SaldosIniciales contadorMovimientos += 1 Dim RowPS As DataRow = ProductosServiciosRef.FiltroPrimero($"Codigo = '{nuevaEntrada("CodigoPS")}' ") If RowPS IsNot Nothing Then + Dim CvePS As Integer = RowPS("CvePS").ToString().ToEntero() Dim CveUM As Integer = RowPS("CveUnidadMedida").ToString().ToEntero() If CveUM > 0 Then @@ -2415,47 +2448,47 @@ Partial Class General_SaldosIniciales Dim PU As Decimal = If(Valor = 0, 0, (Valor / Cantidad)) If Not ObjMovimientos.AddMovimientoDetalle(movimientoCabecera, Cantidad, CveUM, CvePS, PU, -1, -1, Serie:=Serie, Lote:=Lote, FechaCaducidad:=FechaCaducidad) Then - mensajeError = "No se logró generar el detalle del movimiento" + mensajeError.Append("No se logró generar el detalle del movimiento") Throw New Exception() End If Else - mensajeError = $"La unidad de medida no se reconoce para el producto servicio:{nuevaEntrada("CodigoPS")}" + mensajeError.Append($"La unidad de medida no se reconoce para el producto servicio:{nuevaEntrada("CodigoPS")}") Throw New Exception() End If Else - mensajeError = "" '$"No se encontró el producto o servicio con código ""{nuevaEntrada("CodigoPS")}""" - 'Throw New Exception() + mensajeError.Append($"No se encontró el producto o servicio con código ""{nuevaEntrada("CodigoPS")}""
") + ' Throw New Exception() End If Next If contadorMovimientos = 0 Then - mensajeError = $"No se encontraros registros del almacen: ""{almacenActual}""" + mensajeError.Append($"No se encontraros registros del almacen: ""{almacenActual}""") Throw New Exception() Exit For End If Else - mensajeError = $"No se registró el encabezado ""{almacenActual}""" + mensajeError.Append($"No se registró el encabezado ""{almacenActual}""") Throw New Exception() Exit For End If Else - mensajeError = $"No se encontró el almacén con nombre ""{almacenActual}""" + mensajeError.Append($"No se encontró el almacén con nombre ""{almacenActual}""") Throw New Exception() Exit For End If Next Catch ex As Exception - If mensajeError = "" Then - mensajeError = "Error técnico, informar a soporte" & ex.Message + If mensajeError.ToString = "" Then + mensajeError.Append("Error técnico, informar a soporte" & ex.Message) End If ObjMovimientos.RollBack() End Try - If mensajeError = "" Then + If mensajeError.ToString = "" Then ObjMovimientos.Commit() Alert($"Se cargaron correctamente {contadorMovimientos} movimientos

{listadoMovimientos}") Else - Alert(mensajeError, TipoMensaje.MsgError) + Alert(mensajeError.ToString, TipoMensaje.MsgError) ObjMovimientos.RollBack() End If @@ -3083,6 +3116,8 @@ Partial Class General_SaldosIniciales Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoClasificaciones.xlsx" ElseIf RblFormato.SelectedValue = "17" Then Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoClientes-Facturas-Detalles.xlsx" + ElseIf RblFormato.SelectedValue = "18" Then + Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoProveedores-Facturas-Detalles.xlsx" End If If Not (Directorio = "") Then From 717d5f0a8d0a0009335f2d4c9296997d1f7bfec2 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 26 Feb 2024 16:37:41 -0700 Subject: [PATCH 3/3] 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