This commit is contained in:
2023-05-27 12:38:29 -07:00
2 changed files with 312 additions and 27 deletions

View File

@@ -1141,7 +1141,7 @@
<div class="col-md-6 ">
<asp:Button runat="server" ID="btnProrateo" Visible="false" Text="Prorratear" CommandArgument="Compras" CssClass="btn btn-success" />
<asp:Button runat="server" ID="btnProrateo2" Visible="false" Text="Prorratear Nomina" CommandArgument="Nomina" CssClass="btn btn-success" />
<asp:Button runat="server" ID="BtnProrateoDeducible" Visible="false" Text="Prorratear Deducible" CommandArgument="Prorratear Deducible" CssClass="btn btn-success" />
<asp:Button runat="server" ID="BtnProrateoDeducible" Visible="true" Text="Prorratear Deducible" CommandArgument="Prorratear Deducible" CssClass="btn btn-success" />
</div>
</div>

View File

@@ -4560,9 +4560,17 @@ Partial Class Compras_Compras
Exit Sub
End If
'If Not AjustaIVA() Then
' Exit Sub
'End If
If Not AjustaIVA() Then
Exit Sub
End If
If Not AjustaRetIVA() Then
Exit Sub
End If
If Not AjustaRetISR() Then
Exit Sub
End If
If DdlFolioGarantia.Visible AndAlso DdlFolioGarantia.SelectedValue <> "-1" Then
If Not ValidaFolioGarantia() Then Exit Sub
@@ -8042,7 +8050,7 @@ Partial Class Compras_Compras
Dim DiferenciaIVas As Decimal = TxtIVA.Text.ToDecimal - IVADetalles
If Math.Abs(DiferenciaIVas) > 0 Then
If Math.Abs(DiferenciaIVas) > 0.05 Then
If Math.Abs(DiferenciaIVas) <= 0.05 Then
Dim DTConsulta As New DataTable
DTConsulta = TmpDT.FiltraParametros(" IVA > 0 ")
@@ -8113,6 +8121,185 @@ Partial Class Compras_Compras
Alert("existe una diferencia de más de 0.05 entre el IVA de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
Respuesta = False
End If
Else
Respuesta = True
End If
Return Respuesta
End Function
Private Function AjustaRetIVA() As Boolean
Dim Respuesta As Boolean = False
Dim RetIVADetalles As Decimal = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
Dim DiferenciaRetIVA As Decimal = TxtRetIVA.Text.ToDecimal - RetIVADetalles
If Math.Abs(DiferenciaRetIVA) > 0 Then
If Math.Abs(DiferenciaRetIVA) <= 0.05 Then
Dim DTConsulta As New DataTable
DTConsulta = TmpDT.FiltraParametros(" RetIVA > 0 ")
If DTConsulta.Rows.Count > 0 Then
Dim IndiceContador As Integer = 0
Dim IndiceUltimo As Integer = 0
Dim CantidadRegistroConRetIVA As Decimal
For Each dRow As DataRow In TmpDT.Rows
If dRow("RetIVA").ToString.ToDecimal > 0 Then
IndiceUltimo = IndiceContador
CantidadRegistroConRetIVA = CantidadRegistroConRetIVA + 1
End If
IndiceContador = IndiceContador + 1
Next
RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
DiferenciaRetIVA = TxtRetIVA.Text.ToDecimal - RetIVADetalles
If Math.Abs(DiferenciaRetIVA) > 0.0D Then
If (TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA) < 0 Then
Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetIVA) / CantidadRegistroConRetIVA
For Each dRow As DataRow In TmpDT.Rows
dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal - AjusteteDividido
Next
Else
TmpDT.Rows(IndiceUltimo)("RetIVA") = TmpDT.Rows(IndiceUltimo)("RetIVA").ToString.ToDecimal + DiferenciaRetIVA
End If
TmpDT.AcceptChanges()
End If
End If
'Revalidacion de ajuste
RetIVADetalles = TmpDT.SUMD("RetIVA", " RetIVA > 0 ")
DiferenciaRetIVA = TxtRetIVA.Text.ToDecimal - RetIVADetalles
If Math.Abs(DiferenciaRetIVA) > 0.01D Then
Respuesta = False
If RetIVADetalles > 0 Then
For Each dRow As DataRow In TmpDT.Rows
If dRow("RetIVA").ToString.ToDecimal > 0 Then
dRow("RetIVA") = dRow("RetIVA").ToString.ToDecimal + DiferenciaRetIVA
TmpDT.AcceptChanges()
Respuesta = True
Exit For
End If
Next
Else
Alert("Los productos especificados en el listado no tienen asignado impuesto RetIVA, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
Respuesta = False
End If
Else
Respuesta = True
End If
Else
Alert("existe una diferencia de más de 0.05 entre el RetIVA de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
Respuesta = False
End If
Else
Respuesta = True
End If
Return Respuesta
End Function
Private Function AjustaRetISR() As Boolean
Dim Respuesta As Boolean = False
Dim RetISRDetalles As Decimal = TmpDT.SUMD("RetISR", " RetISR > 0 ")
Dim DiferenciaRetISR As Decimal = TxtRetISR.Text.ToDecimal - RetISRDetalles
If Math.Abs(DiferenciaRetISR) > 0 Then
If Math.Abs(DiferenciaRetISR) <= 0.05 Then
Dim DTConsulta As New DataTable
DTConsulta = TmpDT.FiltraParametros(" RetISR > 0 ")
If DTConsulta.Rows.Count > 0 Then
Dim IndiceContador As Integer = 0
Dim IndiceUltimo As Integer = 0
Dim CantidadRegistroConRetISR As Decimal
For Each dRow As DataRow In TmpDT.Rows
If dRow("RetISR").ToString.ToDecimal > 0 Then
IndiceUltimo = IndiceContador
CantidadRegistroConRetISR = CantidadRegistroConRetISR + 1
End If
IndiceContador = IndiceContador + 1
Next
RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ")
DiferenciaRetISR = TxtRetISR.Text.ToDecimal - RetISRDetalles
If Math.Abs(DiferenciaRetISR) > 0.0D Then
If (TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR) < 0 Then
Dim AjusteteDividido As Decimal = Math.Abs(DiferenciaRetISR) / CantidadRegistroConRetISR
For Each dRow As DataRow In TmpDT.Rows
dRow("RetISR") = dRow("RetISR").ToString.ToDecimal - AjusteteDividido
Next
Else
TmpDT.Rows(IndiceUltimo)("RetISR") = TmpDT.Rows(IndiceUltimo)("RetISR").ToString.ToDecimal + DiferenciaRetISR
End If
TmpDT.AcceptChanges()
End If
End If
'Revalidacion de ajuste
RetISRDetalles = TmpDT.SUMD("RetISR", " RetISR > 0 ")
DiferenciaRetISR = TxtRetISR.Text.ToDecimal - RetISRDetalles
If Math.Abs(DiferenciaRetISR) > 0.01D Then
Respuesta = False
If RetISRDetalles > 0 Then
For Each dRow As DataRow In TmpDT.Rows
If dRow("RetISR").ToString.ToDecimal > 0 Then
dRow("RetISR") = dRow("RetISR").ToString.ToDecimal + DiferenciaRetISR
TmpDT.AcceptChanges()
Respuesta = True
Exit For
End If
Next
Else
Alert("Los productos especificados en el listado no tienen asignado impuesto RetISR, favor de realizar la corrección en el producto que aplique el impuesto.", TipoMensaje.MsgAdvertencia)
Respuesta = False
End If
Else
Respuesta = True
End If
Else
Alert("existe una diferencia de más de 0.05 entre el RetISR de la compra y los detalles.", TipoMensaje.MsgAdvertencia)
Respuesta = False
End If
Else
Respuesta = True
End If
Return Respuesta
@@ -20309,18 +20496,99 @@ Partial Class Compras_Compras
End Sub
#End Region
#Region "PRORATEAR DEDUCIBLE"
Private Sub ProratearDeducible()
ChkEsNoDeducible_CheckedChanged1(Nothing, Nothing)
Dim DTProtateo As DataTable = TmpDT.Clone
Dim Consec As Integer = 1
For Each dRowOriginal As DataRow In TmpDT.Rows
Dim DT_Agrupado As DataTable = TmpDT.Clone
Dim DTProtateo As DataTable = TmpDT.Clone
Dim DT_IVAS As DataTable = TmpDT.FiltraParametros("", "", {"IVAPorcentaje", "RetIVAPorcentaje", "RetISRPorcentaje", "IEPSPSPorcentaje", "IEPSPSIVAPorcentaje"})
For Each drIva As DataRow In DT_IVAS.Rows
drIva("IVAPorcentaje") = drIva("IVAPorcentaje").ToString.ToDecimal
drIva("RetIVAPorcentaje") = drIva("RetIVAPorcentaje").ToString.ToDecimal
drIva("RetISRPorcentaje") = drIva("RetISRPorcentaje").ToString.ToDecimal
drIva("IEPSPSPorcentaje") = drIva("IEPSPSPorcentaje").ToString.ToDecimal
drIva("IEPSPSIVAPorcentaje") = drIva("IEPSPSIVAPorcentaje").ToString.ToDecimal
Next
DT_IVAS.AcceptChanges()
For Each dRow As DataRow In TmpDT.Rows
dRow("IVAPorcentaje") = dRow("IVAPorcentaje").ToString.ToDecimal
dRow("RetIVAPorcentaje") = dRow("RetIVAPorcentaje").ToString.ToDecimal
dRow("RetISRPorcentaje") = dRow("RetISRPorcentaje").ToString.ToDecimal
dRow("IEPSPSPorcentaje") = dRow("IEPSPSPorcentaje").ToString.ToDecimal
dRow("IEPSPSIVAPorcentaje") = dRow("IEPSPSIVAPorcentaje").ToString.ToDecimal
Next
TmpDT.AcceptChanges()
Dim psCvePs As Integer = 700562
Dim rowPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, psCvePs).Rows(0)
Dim psPSCodigo As String = rowPS("PSCodigo").ToString
Dim psCveClasificacion As Integer = rowPS("CveClasificacion").ToString.ToEntero
Dim psClasificacion As String = rowPS("Clasificacion").ToString
Dim psCveUM As Integer = rowPS("CveUM").ToString.ToEntero
Dim psUM As String = rowPS("UnidadMedida").ToString
For Each drIva As DataRow In DT_IVAS.Rows
Dim nRowAgrupado As DataRow = DT_Agrupado.NewRow
Dim drIVAPorcentaje As Decimal = drIva("IVAPorcentaje").ToString.ToDecimal
Dim drRetIVAPorcentaje As Decimal = drIva("RetIVAPorcentaje").ToString.ToDecimal
Dim drRetISRPorcentaje As Decimal = drIva("RetISRPorcentaje").ToString.ToDecimal
Dim drIEPSPSPorcentaje As Decimal = drIva("IEPSPSPorcentaje").ToString.ToDecimal
Dim drIEPSPSIVAPorcentaje As Decimal = drIva("IEPSPSIVAPorcentaje").ToString.ToDecimal
nRowAgrupado("Consec") = Consec
nRowAgrupado("Cantidad") = 1
nRowAgrupado("CveUM") = psCveUM
nRowAgrupado("UM") = psUM
nRowAgrupado("CvePS") = psCvePs
nRowAgrupado("PS") = psPSCodigo
nRowAgrupado("CveClasificacion") = psCveClasificacion
nRowAgrupado("Clasificacion") = psClasificacion
nRowAgrupado("IVAPorcentaje") = drIva("IVAPorcentaje")
nRowAgrupado("RetIVAPorcentaje") = drIva("RetIVAPorcentaje")
nRowAgrupado("RetISRPorcentaje") = drIva("RetISRPorcentaje")
nRowAgrupado("IEPSPSPorcentaje") = drIva("IEPSPSPorcentaje")
nRowAgrupado("IEPSPSIVAPorcentaje") = drIva("IEPSPSIVAPorcentaje")
nRowAgrupado("PU") = TmpDT.SUMD("PU", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("IVA") = TmpDT.SUMD("IVA", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("RetIVA") = TmpDT.SUMD("RetIVA", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("RetISR") = TmpDT.SUMD("RetISR", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("IEPSPS") = TmpDT.SUMD("IEPSPS", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("IEPSPSIVA") = TmpDT.SUMD("IEPSPSIVA", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("Descuento") = TmpDT.SUMD("Descuento", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("Total") = TmpDT.SUMD("Total", $" IVAPorcentaje={drIVAPorcentaje} AND RetIVAPorcentaje = {drRetIVAPorcentaje} AND RetISRPorcentaje= {drRetISRPorcentaje} AND IEPSPSPorcentaje = {drIEPSPSPorcentaje} AND IEPSPSIVAPorcentaje = {drIEPSPSIVAPorcentaje} ")
nRowAgrupado("NoDeducible") = 0
Consec = Consec + 1
DT_Agrupado.Rows.Add(nRowAgrupado)
Next
DT_Agrupado.AcceptChanges()
Consec = 1
For Each dRowOriginal As DataRow In DT_Agrupado.Rows
@@ -20330,23 +20598,11 @@ Partial Class Compras_Compras
dRow91_5.ItemArray = dRowOriginal.ItemArray
dRow8_5.ItemArray = dRowOriginal.ItemArray
Dim Mul91_5 As Decimal = 0.915D
Dim Mul85 As Decimal = 0.085D
Dim Mul91_5 As Decimal = 0.915D
dRow91_5("Consec") = Consec
dRow91_5("PU") = dRow91_5("PU").ToString.ToDecimal * Mul91_5
dRow91_5("IVA") = dRow91_5("IVA").ToString.ToDecimal * Mul91_5
dRow91_5("RetIVA") = dRow91_5("RetIVA").ToString.ToDecimal * Mul91_5
dRow91_5("RetISR") = dRow91_5("RetISR").ToString.ToDecimal * Mul91_5
dRow91_5("IEPSPS") = dRow91_5("IEPSPS").ToString.ToDecimal * Mul91_5
dRow91_5("IEPSPSIVA") = dRow91_5("IEPSPSIVA").ToString.ToDecimal * Mul91_5
dRow91_5("Descuento") = dRow91_5("Descuento").ToString.ToDecimal * Mul91_5
dRow91_5("Total") = dRow91_5("Total").ToString.ToDecimal * Mul91_5
dRow91_5("NoDeducible") = 1
dRow8_5("Consec") = Consec + 1
dRow8_5("Consec") = Consec
dRow8_5("PU") = dRow8_5("PU").ToString.ToDecimal * Mul85
dRow8_5("IVA") = dRow8_5("IVA").ToString.ToDecimal * Mul85
dRow8_5("RetIVA") = dRow8_5("RetIVA").ToString.ToDecimal * Mul85
@@ -20358,8 +20614,40 @@ Partial Class Compras_Compras
dRow8_5("NoDeducible") = 0
DTProtateo.Rows.Add(dRow91_5)
psCvePs = 700563
rowPS = GlobalDTPS(UsuarioActual.CveEmpresa, psCvePs).Rows(0)
psPSCodigo = rowPS("PSCodigo").ToString
psCveClasificacion = rowPS("CveClasificacion").ToString.ToEntero
psClasificacion = rowPS("Clasificacion").ToString
psCveUM = rowPS("CveUM").ToString.ToEntero
psUM = rowPS("UnidadMedida").ToString
dRow91_5("CveUM") = psCveUM
dRow91_5("UM") = psUM
dRow91_5("CvePS") = psCvePs
dRow91_5("PS") = psPSCodigo
dRow91_5("CveClasificacion") = psCveClasificacion
dRow91_5("Clasificacion") = psClasificacion
dRow91_5("Consec") = Consec + 1
dRow91_5("PU") = dRow91_5("PU").ToString.ToDecimal * Mul91_5
dRow91_5("IVA") = dRow91_5("IVA").ToString.ToDecimal * Mul91_5
dRow91_5("RetIVA") = dRow91_5("RetIVA").ToString.ToDecimal * Mul91_5
dRow91_5("RetISR") = dRow91_5("RetISR").ToString.ToDecimal * Mul91_5
dRow91_5("IEPSPS") = dRow91_5("IEPSPS").ToString.ToDecimal * Mul91_5
dRow91_5("IEPSPSIVA") = dRow91_5("IEPSPSIVA").ToString.ToDecimal * Mul91_5
dRow91_5("Descuento") = dRow91_5("Descuento").ToString.ToDecimal * Mul91_5
dRow91_5("Total") = dRow91_5("Total").ToString.ToDecimal * Mul91_5
dRow91_5("NoDeducible") = 1
DTProtateo.Rows.Add(dRow8_5)
DTProtateo.Rows.Add(dRow91_5)
Consec = Consec + 2
@@ -20378,12 +20666,9 @@ Partial Class Compras_Compras
ProratearDeducible()
End Sub
#End Region
End Class