-- cambios en registro rápido de facturas

This commit is contained in:
2023-07-21 11:03:56 -07:00
parent 12e4e4c3db
commit 9346e26717
2 changed files with 72 additions and 221 deletions

View File

@@ -108,24 +108,22 @@
<div class="titlefiltros "> <div class="titlefiltros ">
<div class="row" style="padding-top: 10px"> <div class="row" style="padding-top: 10px">
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" >
Folio: Folio:
</div> </div>
<div class="col-md-1"> <div class="col-md-1">
<asp:TextBox ID="TxtFolio" runat="server" MaxLength="50" CssClass="form-control input-sm"></asp:TextBox> <asp:TextBox ID="TxtFolio" runat="server" MaxLength="50" CssClass="form-control input-sm"></asp:TextBox>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Proveedor: Proveedor:
</div> </div>
<div class="col-md-2 "> <div class="col-md-2 ">
<asp:TextBox ID="TxtProveedor" runat="server" MaxLength="50" CssClass="form-control input-sm"></asp:TextBox> <asp:TextBox ID="TxtProveedor" runat="server" MaxLength="50" CssClass="form-control input-sm"></asp:TextBox>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Fecha I.: Fecha I.:
</div> </div>
<div class="col-md-1" style="min-width:125px!important;margin-left:-9px!important"> <div class="col-md-1" style="min-width:125px!important;margin-left:-9px!important">
@@ -145,10 +143,10 @@
<ajax:ValidatorCalloutExtender ID="vcoCvFI" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaI" Width="350px"></ajax:ValidatorCalloutExtender> <ajax:ValidatorCalloutExtender ID="vcoCvFI" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaI" Width="350px"></ajax:ValidatorCalloutExtender>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:130px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Fecha F.: Fecha F.:
</div> </div>
<div class="col-md-1" style="min-width:125px!important;margin-left:-1px!important"> <div class="col-md-1" style="min-width:120px!important;margin-left:-1px!important">
<div class="input-group input-sm date date-picker " data-date-format="dd/mm/yyyy" style="display: inline-block;margin-top:-7px""> <div class="input-group input-sm date date-picker " data-date-format="dd/mm/yyyy" style="display: inline-block;margin-top:-7px"">
<asp:TextBox ID="txtFechaF" runat="server" CssClass="form-control input-sm" CausesValidation="true" MaxLength="10" Width="82px "></asp:TextBox> <asp:TextBox ID="txtFechaF" runat="server" CssClass="form-control input-sm" CausesValidation="true" MaxLength="10" Width="82px "></asp:TextBox>
<span class="input-group-btn "> <span class="input-group-btn ">
@@ -163,7 +161,7 @@
<ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender> <ajax:ValidatorCalloutExtender ID="vcoCvFF" runat="server" HighlightCssClass="vco" TargetControlID="cvFechaF" Width="350px"></ajax:ValidatorCalloutExtender>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Estatus: Estatus:
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
@@ -177,21 +175,14 @@
<asp:ListItem Text="Omitidas" Value="5"></asp:ListItem> <asp:ListItem Text="Omitidas" Value="5"></asp:ListItem>
<asp:ListItem Text="Todas" Value="-1"></asp:ListItem> <asp:ListItem Text="Todas" Value="-1"></asp:ListItem>
</asp:DropDownList> </asp:DropDownList>
</div> </div>
</div>
</div>
</div>
</div>
</div> </div>
<div class="portlet-body" style="display: none;"> <div class="portlet-body" style="display: none;">
<div class="row"> <div class="row">
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Responsable: Responsable:
</div> </div>
<div class="col-md-1"> <div class="col-md-1">
@@ -199,7 +190,7 @@
Class="form-control select2me input-sm"></asp:DropDownList> Class="form-control select2me input-sm"></asp:DropDownList>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Clasificación: Clasificación:
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
@@ -207,7 +198,7 @@
Class="form-control select2me input-sm"></asp:DropDownList> Class="form-control select2me input-sm"></asp:DropDownList>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:100px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Tipo Prov: Tipo Prov:
</div> </div>
<div class="col-md-1"> <div class="col-md-1">
@@ -219,7 +210,7 @@
</asp:DropDownList> </asp:DropDownList>
</div> </div>
<div class="col-md-1 input-sm truncate" style="text-align:right;max-width:130px!important" > <div class="col-md-1 input-sm truncate" style="text-align:right;max-width:80px!important" >
Tipo Comprobante: Tipo Comprobante:
</div> </div>
<div class="col-md-1"> <div class="col-md-1">
@@ -229,9 +220,7 @@
<asp:ListItem Selected="False" Text="Egresos" Value="E"></asp:ListItem> <asp:ListItem Selected="False" Text="Egresos" Value="E"></asp:ListItem>
</asp:DropDownList> </asp:DropDownList>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</ContentTemplate> </ContentTemplate>
@@ -281,20 +270,24 @@
<asp:ListItem Value="6" Selected="True" >Caja Chica</asp:ListItem> <asp:ListItem Value="6" Selected="True" >Caja Chica</asp:ListItem>
<asp:ListItem Value="2">Viáticos</asp:ListItem> <asp:ListItem Value="2">Viáticos</asp:ListItem>
</asp:RadioButtonList> </asp:RadioButtonList>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="form-group form-md-line-input input-iconright" > <div>
<div class="form-group form-md-line-input input-iconright col-md-6" >
<asp:DropDownList ID="DdlRetIVAConcepto" AppendDataBoundItems="true" CssClass="form-control input-sm select2me" Style="width: 100%;" runat="server"></asp:DropDownList> <asp:DropDownList ID="DdlRetIVAConcepto" AppendDataBoundItems="true" CssClass="form-control input-sm select2me" Style="width: 100%;" runat="server"></asp:DropDownList>
<label runat="server" id="LblRetIVAConcepto" for="<%= DdlRetIVAConcepto.ClientID.ToString()%>">Ret. IVA:</label> <label runat="server" id="LblRetIVAConcepto" for="<%= DdlRetIVAConcepto.ClientID.ToString()%>">Ret. IVA:</label>
</div> </div>
</div> <div class="form-group form-md-line-input input-iconright col-md-6" >
<asp:DropDownList ID="DdlRetISRConcepto" AppendDataBoundItems="true" CssClass="form-control input-sm select2me" Style="width: 100%;" runat="server"></asp:DropDownList>
<label runat="server" id="LblRetISRConcepto" for="<%= DdlRetISRConcepto.ClientID.ToString()%>">Ret. ISR:</label>
</div>
</div>
</div>
</div> </div>
@@ -321,12 +314,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="form-group form-md-line-input input-iconright" >
<asp:DropDownList ID="DdlRetISRConcepto" AppendDataBoundItems="true" CssClass="form-control input-sm select2me" Style="width: 100%;" runat="server"></asp:DropDownList>
<label runat="server" id="LblRetISRConcepto" for="<%= DdlRetISRConcepto.ClientID.ToString()%>">Ret. ISR:</label>
</div>
</div> </div>

View File

@@ -5086,7 +5086,6 @@ Partial Class Compras_eFacturas
cargasolicitudes() cargasolicitudes()
End If End If
End Sub End Sub
@@ -5306,9 +5305,6 @@ Partial Class Compras_eFacturas
#End Region #End Region
Protected Sub LnkRegistarFactura_Click(sender As Object, e As EventArgs) Protected Sub LnkRegistarFactura_Click(sender As Object, e As EventArgs)
DVRegistraFacturas.Visible = True DVRegistraFacturas.Visible = True
GvD.Columns(0).Visible = True GvD.Columns(0).Visible = True
@@ -5323,14 +5319,11 @@ Partial Class Compras_eFacturas
Dim Contador As Integer = 0 Dim Contador As Integer = 0
Dim ErrorProcesoStr As String = "" Dim ErrorProcesoStr As String = ""
If Not DdlPS.SelectedValue.ToEntero > 0 Then If Not DdlPS.SelectedValue.ToEntero > 0 Then
Alert("Debe seleccionar un producto", TipoMensaje.MsgAdvertencia) Alert("Debe seleccionar un producto", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
For Each GvRow As GridViewRow In GvD.Rows For Each GvRow As GridViewRow In GvD.Rows
If GvRow.FCCheckBox("chkRegistraFactura").Checked Then If GvRow.FCCheckBox("chkRegistraFactura").Checked Then
@@ -5351,7 +5344,6 @@ Partial Class Compras_eFacturas
CompraActual.Descripcion = TxtDescripcionCompra.Text.Trim CompraActual.Descripcion = TxtDescripcionCompra.Text.Trim
CompraActual.NombreProveedor = GvRow.DataKey("NombreProveedor") CompraActual.NombreProveedor = GvRow.DataKey("NombreProveedor")
Dim CvePersonal As Integer = -1 'DdlPersonalReembolso.SelectedValue.ToEntero Dim CvePersonal As Integer = -1 'DdlPersonalReembolso.SelectedValue.ToEntero
Dim CveCajachica As Integer = -1 'DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero Dim CveCajachica As Integer = -1 'DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero
@@ -5367,15 +5359,12 @@ Partial Class Compras_eFacturas
Contador = Contador + 1 Contador = Contador + 1
Else Else
ErrorProceso = True ErrorProceso = True
ErrorProcesoStr = CompraActual.MSG_Error ErrorProcesoStr = CompraActual.MensajeError
Exit For Exit For
End If End If
End If End If
Next Next
If Not ErrorProceso Then If Not ErrorProceso Then
CargaDatos() CargaDatos()
If Contador > 0 Then If Contador > 0 Then
@@ -5385,9 +5374,8 @@ Partial Class Compras_eFacturas
Alert($"Se registraron {Contador} Compras. error {ErrorProcesoStr}", TipoMensaje.MsgAdvertencia) Alert($"Se registraron {Contador} Compras. error {ErrorProcesoStr}", TipoMensaje.MsgAdvertencia)
End If End If
End Sub End Sub
End Class End Class
Public Class Compra2 Public Class Compra2
@@ -5593,7 +5581,6 @@ Public Class Compra2
Public Property TotalTraslados As Decimal = 0D Public Property TotalTraslados As Decimal = 0D
Public Property TrasladoIVA As Decimal = 0D Public Property TrasladoIVA As Decimal = 0D
Public Property TrasladoIEPS As Decimal = 0D Public Property TrasladoIEPS As Decimal = 0D
Public Property TrasladoIEP As Decimal = 0D
Public Property SumaTotalTraslados As Decimal = 0D Public Property SumaTotalTraslados As Decimal = 0D
Public Property OtrosImpuestos As Decimal = 0D Public Property OtrosImpuestos As Decimal = 0D
Private Property OtrosImpuestosRetenciones As Decimal = 0D Private Property OtrosImpuestosRetenciones As Decimal = 0D
@@ -5604,9 +5591,8 @@ Public Class Compra2
Public Property XMlStr As String Public Property XMlStr As String
Public Property XMLCargaExistosa As Boolean = True Public Property XMLCargaExistosa As Boolean = True
Public Property Observaciones As String = "" Public Property Observaciones As String = ""
Public Property CveEstatusFactura As Integer = -1 Public Property CveEstatusFactura As Integer = 1
Public Property CvePrePoliza As Integer = -1 Public Property CvePrePoliza As Integer = -1
Public Property Redondeo As Decimal = 0 Public Property Redondeo As Decimal = 0
Public Property IdPoliza As Integer = -1 Public Property IdPoliza As Integer = -1
@@ -5628,7 +5614,7 @@ Public Class Compra2
Private Errores As StringBuilder = New StringBuilder Private Errores As StringBuilder = New StringBuilder
Public ReadOnly Property MSG_Error As String Public ReadOnly Property MensajeError As String
Get Get
Return Errores.ToString() Return Errores.ToString()
End Get End Get
@@ -5699,7 +5685,6 @@ Public Class Compra2
CargaComprobanteXML(XMLDoc) CargaComprobanteXML(XMLDoc)
End If End If
End Sub End Sub
Private Sub CargaDesdeString(XmlFuente As String) Private Sub CargaDesdeString(XmlFuente As String)
XMlStr = XmlFuente.Replace("&lt;br&gt;", "").Replace("&lt;", "").Replace("o;?", "") XMlStr = XmlFuente.Replace("&lt;br&gt;", "").Replace("&lt;", "").Replace("o;?", "")
@@ -5717,10 +5702,8 @@ Public Class Compra2
CargaComprobanteXML(XMLDoc) CargaComprobanteXML(XMLDoc)
End If End If
End Sub End Sub
Private Sub CargaComprobanteXML(XMLDoc As XmlDocument) Private Sub CargaComprobanteXML(XMLDoc As XmlDocument)
Dim nodo As XmlNode = XMLDoc.DocumentElement Dim nodo As XmlNode = XMLDoc.DocumentElement
@@ -5728,7 +5711,6 @@ Public Class Compra2
Dim StrCFDIVerion As String = ValorXML(nodo, "version") Dim StrCFDIVerion As String = ValorXML(nodo, "version")
If StrCFDIVerion = "3.2" Then If StrCFDIVerion = "3.2" Then
CFDIVersion = EnumCFDIVersion.v32 CFDIVersion = EnumCFDIVersion.v32
ElseIf StrCFDIVerion = "3.3" Then ElseIf StrCFDIVerion = "3.3" Then
@@ -5916,7 +5898,6 @@ Public Class Compra2
#Region "DETALLES" #Region "DETALLES"
Dim ObjeFacturas As New ClsCompras Dim ObjeFacturas As New ClsCompras
Dim AjustaUltimoConcepto = False Dim AjustaUltimoConcepto = False
@@ -5967,11 +5948,8 @@ Public Class Compra2
End If End If
TmpDT.AcceptChanges() TmpDT.AcceptChanges()
ValidacionesTotalesXml() ValidacionesTotalesXml()
End If End If
Me.PorcentajeIVA = TmpDT.MAX("IVAPorcentaje").ToDecimal Me.PorcentajeIVA = TmpDT.MAX("IVAPorcentaje").ToDecimal
#End Region #End Region
@@ -6786,7 +6764,6 @@ Public Class Compra2
Row("IVAPorcentaje") = IVA Row("IVAPorcentaje") = IVA
End If End If
Row("RetIVA") = (RetIVA * Total).RoundSQL Row("RetIVA") = (RetIVA * Total).RoundSQL
Row("RetIVAPorcentaje") = RetIVA Row("RetIVAPorcentaje") = RetIVA
Row("RetISR") = (RetISR * Total).RoundSQL Row("RetISR") = (RetISR * Total).RoundSQL
@@ -6819,16 +6796,11 @@ Public Class Compra2
Row("CveTipoGastoAC") = CveTipoGastoAC Row("CveTipoGastoAC") = CveTipoGastoAC
Row("CveClasificacionOG") = CveClasificacionOG Row("CveClasificacionOG") = CveClasificacionOG
End If End If
'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere 'Esta parte es para validar cuando la factura tenga ieps en o se asignara el ieps como una partida ya no se considere
If (CveFactura > 0 Or CveCompra > 0) And IEPS = 0 Then If (CveFactura > 0 Or CveCompra > 0) And IEPS = 0 Then
Row("IEPSPS") = 0 Row("IEPSPS") = 0
Row("IEPSPSPorcentaje") = 0 Row("IEPSPSPorcentaje") = 0
End If End If
TmpDT.Rows.Add(Row) TmpDT.Rows.Add(Row)
TmpDT.Rows.IndexOf(Row) TmpDT.Rows.IndexOf(Row)
@@ -6899,9 +6871,6 @@ Public Class Compra2
CompraSaldo = LocalTotal CompraSaldo = LocalTotal
End If End If
Me.NumNoDed = TmpDT.COUNT("CvePS", "NoDeducible = True ") Me.NumNoDed = TmpDT.COUNT("CvePS", "NoDeducible = True ")
@@ -6923,9 +6892,6 @@ Public Class Compra2
Return False Return False
End Try End Try
'DATOS GENERALES 'DATOS GENERALES
DrPS("Obs") = "" DrPS("Obs") = ""
DrPS("Proyecto") = Proyecto DrPS("Proyecto") = Proyecto
@@ -6972,23 +6938,14 @@ Public Class Compra2
DrPS("CveCultivoCuadroDetalle") = -1 DrPS("CveCultivoCuadroDetalle") = -1
DrPS("TemporadaCuadro") = "" DrPS("TemporadaCuadro") = ""
Else Else
Errores.AppendLine($"No se encontrol el producto con CvePS {CvePS}") Errores.AppendLine($"No se encontrol el producto con CvePS {CvePS}")
Respuesta = False Respuesta = False
End If End If
TmpDT.AcceptChanges() TmpDT.AcceptChanges()
Return Respuesta Return Respuesta
End Function End Function
Private Sub ValidacionesTotalesXml() Private Sub ValidacionesTotalesXml()
If Not TmpDT.Columns.Contains("Amortizacion") Then If Not TmpDT.Columns.Contains("Amortizacion") Then
@@ -7005,7 +6962,6 @@ Public Class Compra2
Dim RetISRTemp = TmpDT.SUMD("RetISR") Dim RetISRTemp = TmpDT.SUMD("RetISR")
Dim TotalTemp As Decimal = Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones Dim TotalTemp As Decimal = Subtotal2Temp - RetIVATemp - RetISRTemp + Math.Round(IVATemp, 6) + IEPSTemp + OtrosImpuestos - OtrosImpuestosRetenciones
If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuento, 6)) > 0.01 Then If Math.Abs(Math.Round(DescuentosTemp, 6) - Math.Round(Descuento, 6)) > 0.01 Then
Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general <br>") Msg &= String.Format("- Los descuentos del detalle no coinciden con el descuento general <br>")
End If End If
@@ -7050,12 +7006,8 @@ Public Class Compra2
Me.RetIVA = RetIVATemp Me.RetIVA = RetIVATemp
Me.RetISR = RetISRTemp Me.RetISR = RetISRTemp
Me.IEPS = IEPSTemp Me.IEPS = IEPSTemp
CompraSaldo = TotalTemp CompraSaldo = TotalTemp
AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total) AsignaValoresOriginales(SubtotalTemp, Subtotal2Temp, IVATemp, RetIVATemp, RetISRTemp, Total)
End Sub End Sub
@@ -7075,7 +7027,6 @@ Public Class Compra2
Dim Amortizacion As Decimal = 0 Dim Amortizacion As Decimal = 0
If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste
Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1) Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1)
Dim tPU As Decimal Dim tPU As Decimal
@@ -7109,11 +7060,8 @@ Public Class Compra2
SubTotalConceptos = SubTotal SubTotalConceptos = SubTotal
End Sub End Sub
Public Function ValidateUUID(ByVal uuid As String) As Boolean Public Function ValidateUUID(ByVal uuid As String) As Boolean
Dim pattern As String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" Dim pattern As String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
Dim regex As New Regex(pattern) Dim regex As New Regex(pattern)
@@ -7149,26 +7097,19 @@ Public Class Compra2
End If End If
End Function End Function
Public Function AddCompra() As Boolean Public Function AddCompra() As Boolean
If Not AjustesValidacion() Then If Not AjustesValidacion() Then Return False
Return False
End If
Dim respuesta As Boolean = True Dim respuesta As Boolean = True
Dim ObjCompras As New ClsCompras Dim ObjCompras As New ClsCompras
ObjCompras.IniciaTransacSQL() Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
If Not AddPrepolizaCabecera(ObjCompras.IniciaTransacSQL()) Then If Not AddPrepolizaCabecera(ObjConta) Then
respuesta = False respuesta = False
End If End If
If respuesta And ObjCompras.AddCompra("Fac", Me.Descripcion, Me.Serie, Me.Folio, Me.FolioSecundario, Me.CveProveedor, Me.SubTotal, Me.Descuento, If respuesta AndAlso ObjCompras.AddCompra(If(Me.TipoComprobante = "I", "Fac", "NC"), Me.Descripcion, Me.Serie, Me.Folio, Me.FolioSecundario, Me.CveProveedor, Me.SubTotal, Me.Descuento,
Me.Amortizacion, Me.IVA, Me.RetIVA, Me.RetISR, Me.IEPS, Me.OtrosImpuestos, Me.Amortizacion, Me.IVA, Me.RetIVA, Me.RetISR, Me.IEPS, Me.OtrosImpuestos,
Me.Redondeo, Me.Total, Me.Fecha, Me.CveMoneda, Me.TipoCambio, If(Me.FechaPago = Nothing, Me.Fecha, Me.FechaPago), Me.AplicaNotaCredito, Me.Observaciones, Me.CveEstatusFactura, Me.Redondeo, Me.Total, Me.Fecha, Me.CveMoneda, Me.TipoCambio, If(Me.FechaPago = Nothing, Me.Fecha, Me.FechaPago), Me.AplicaNotaCredito, Me.Observaciones, Me.CveEstatusFactura,
Me.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.IdPoliza, CveCajaChica:=Me.CveCajaChica, CvePersonal:=Me.CvePersonal, NumeroReembolso:=Me.NumeroReembolso, CveProveedorSucursal:=Me.CveProveedorSucursal, Me.CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.IdPoliza, CveCajaChica:=Me.CveCajaChica, CvePersonal:=Me.CvePersonal, NumeroReembolso:=Me.NumeroReembolso, CveProveedorSucursal:=Me.CveProveedorSucursal,
@@ -7181,7 +7122,6 @@ Public Class Compra2
respuesta = False respuesta = False
End If End If
If respuesta AndAlso Me.CveCompra > 0 Then If respuesta AndAlso Me.CveCompra > 0 Then
For Each Row As DataRow In Me.TmpDT.Rows For Each Row As DataRow In Me.TmpDT.Rows
@@ -7209,14 +7149,10 @@ Public Class Compra2
End If End If
If respuesta Then If respuesta Then
If Not AddPrepolizaDetalles(transaccion:=ObjCompras.IniciaTransacSQL()) Then If Not AddPrepolizaDetalles(ObjConta) Then respuesta = False
respuesta = False
End If
End If End If
If respuesta AndAlso ObjConta.ValidacionesPrePoliza(CvePrePoliza, UsuarioActual, 4) Then
Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
If respuesta AndAlso ObjConta.ValidacionPrePolizaCuadre(CvePrePoliza, 4) Then
If ObjConta.ValorPolizaDescuadre > 0 Then If ObjConta.ValorPolizaDescuadre > 0 Then
Errores.AppendLine($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}.") Errores.AppendLine($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}.")
GuardaLogAD($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") GuardaLogAD($"eFacturas/Compras-Guardar | Error{ObjConta.MensajePolizaDescuadre} Diferencia{ObjConta.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
@@ -7225,12 +7161,9 @@ Public Class Compra2
End If End If
If respuesta Then If respuesta Then
If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then respuesta = False
respuesta = False
End If
End If End If
If respuesta Then If respuesta Then
ObjCompras.Commit() ObjCompras.Commit()
Else Else
@@ -7238,134 +7171,81 @@ Public Class Compra2
End If End If
ObjCompras.Dispose() ObjCompras.Dispose()
ObjConta.Dispose()
Return respuesta Return respuesta
End Function End Function
Private Function AddPrepolizaCabecera(ByRef ObjConta As ClsContabilidad) As Boolean
Private Function AddPrepolizaCabecera(Optional transaccion As SqlTransaction = Nothing) As Boolean
Dim respuesta As Boolean = False Dim respuesta As Boolean = False
Dim ObjConta As ClsContabilidad
Dim DisposeClases As Boolean
If transaccion IsNot Nothing Then
ObjConta = New ClsContabilidad(transaccion)
DisposeClases = False
Else
ObjConta = New ClsContabilidad
DisposeClases = True
End If
Dim ConceptoPoliza As String = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "") Dim ConceptoPoliza As String = String.Format("{0} - {1} - {2}", NombreProveedor, SerieFolio, "")
Me.CvePrePoliza = ObjConta.AddPrePolizas("eFacturas/Registrar", 1, Me.Total, Me.Total, Me.CveMoneda, Me.Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", CveTipoPoliza:=Me.CveTipoPoliza) Me.CvePrePoliza = ObjConta.AddPrePolizas("eFacturas/Registrar", 1, Me.Total, Me.Total, Me.CveMoneda, Me.Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0, "", CveTipoPoliza:=Me.CveTipoPoliza)
respuesta = If(Me.CvePrePoliza > 0, True, False) respuesta = If(Me.CvePrePoliza > 0, True, False)
If DisposeClases Then
ObjConta.Dispose()
End If
Return respuesta Return respuesta
End Function End Function
Private Function AddPrepolizaDetalles(transaccion As SqlTransaction) As Boolean Private Function AddPrepolizaDetalles(ByRef ObjConta As ClsContabilidad) As Boolean
Dim respuesta As Boolean = True Dim respuesta As Boolean = True
Dim ObjConta As ClsContabilidad
Dim DisposeClases As Boolean
If transaccion IsNot Nothing Then
ObjConta = New ClsContabilidad(transaccion)
DisposeClases = False
Else
ObjConta = New ClsContabilidad
DisposeClases = True
End If
Dim Concepto As String = $"{Me.NombreProveedor} {Me.SerieFolio}" Dim Concepto As String = $"{Me.NombreProveedor} {Me.SerieFolio}"
Dim Referencia As String = Me.SerieFolio Dim Referencia As String = Me.SerieFolio
Dim importeMovimiento As Decimal
'TC del xml Dim importeMN As Decimal
'6 '6
For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2", "", {"CveClasificacion", "CveSubProyecto"}).Rows
Dim importe = TmpDT.SUMD("Total", $" CveClasificacion = {RowDetalle("CveClasificacion").ToString} AND CveSubProyecto = {RowDetalle("CveSubProyecto").ToString}") importeMovimiento = TmpDT.SUMD("Total", $" CveClasificacion = {RowDetalle("CveClasificacion").ToString} AND CveSubProyecto = {RowDetalle("CveSubProyecto").ToString}")
Dim importeMN = importe * Me.TipoCambio importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
If importeMN <> 0 Then If importeMN <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, Referencia, 6, Concepto, Me.Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=Me.CveCreditoDetalle, ImporteMX:=importeMN, ImporteME:=If(TipoCambio = 1, 0, importe), TipoCambio:=TipoCambio, If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 6, Referencia, Concepto, -1, CveCompra:=CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=Me.CveCreditoDetalle, ImporteME:=If(TipoCambio = 1, 0, importeMovimiento), TipoCambio:=TipoCambio,
CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=True) Then CveClasificacion:=RowDetalle("CveClasificacion").ToString().ToEntero(), CveSubProyecto:=RowDetalle("CveSubProyecto").ToString().ToEntero(), Contabilizable:=True) Then
respuesta = False respuesta = False
Exit For Exit For
End If End If
End If End If
Next Next
'14 '14
If Me.IVA > 0 Then If respuesta AndAlso Me.IVA > 0 Then
Dim importeMovimiento As Decimal = Me.IVA importeMovimiento = Me.IVA
Dim importeMN As Decimal = importeMovimiento * Me.TipoCambio importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, importeMN, 14, Referencia, Concepto, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=Me.PorcentajeIVA, Contabilizable:=True) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importeMovimiento, Referencia, 14, Concepto, Me.Fecha, -1, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=Me.PorcentajeIVA, Contabilizable:=True) Then
respuesta = False respuesta = False
End If End If
End If End If
'25 '25
If Me.IEPS > 0 Then If respuesta AndAlso Me.IEPS > 0 Then
Dim importeMovimiento As Decimal = Me.IEPS importeMovimiento = Me.IEPS
Dim importeMN As Decimal = importeMovimiento * Me.TipoCambio importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, 25, Referencia, Concepto, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, 25, Concepto, Me.Fecha, -1, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
respuesta = False respuesta = False
End If End If
End If End If
'
If respuesta AndAlso Me.RetIVA > 0 Then
If Me.RetIVA > 0 Then importeMovimiento = Me.RetIVA
Dim importeMovimiento As Decimal = Me.RetIVA importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
Dim importeMN As Decimal = importeMovimiento * Me.TipoCambio
Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetIVA Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetIVA
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, ret.CveConceptoxAcreditar, Concepto, Me.Fecha, -1, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
respuesta = False respuesta = False
End If End If
End If End If
'
If Me.RetISR > 0 Then If respuesta AndAlso Me.RetISR > 0 Then
Dim importeMovimiento As Decimal = Me.RetISR importeMovimiento = Me.RetISR
Dim importeMN As Decimal = importeMovimiento * Me.TipoCambio importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetISR Dim ret As ConceptosRetenciones = ConceptoPrePolizaRetISR
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ret.CveConceptoxAcreditar, Referencia, Concepto, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, ret.CveConceptoxAcreditar, Concepto, Me.Fecha, -1, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
respuesta = False respuesta = False
End If End If
End If End If
'5 '5
If respuesta Then If respuesta Then
importeMovimiento = Me.Total
importeMN = (importeMovimiento * Me.TipoCambio).RoundSQL
Dim importeMovimiento As Decimal = Me.Total
Dim importeMN As Decimal = importeMovimiento * Me.TipoCambio
Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(1, Me.CveMoneda, False, Me.CveTipoConceptoProveedor) Dim ConPreP As ConceptosTipoSaldo = ObtenerCveConceptoPrePoliza(1, Me.CveMoneda, False, Me.CveTipoConceptoProveedor)
Dim ImporteME = importeMovimiento Dim ImporteME = importeMovimiento
Dim UsaComplementaria As Boolean = True Dim UsaComplementaria As Boolean = True
If Me.CveMoneda > 1 Then ImporteME = importeMovimiento If Me.CveMoneda > 1 Then ImporteME = importeMovimiento
@@ -7375,34 +7255,17 @@ Public Class Compra2
Else Else
importeMN = importeMovimiento importeMN = importeMovimiento
End If End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, importeMN, ConPreP.CveConcepto, Referencia, Concepto, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
respuesta = False
End If
If respuesta AndAlso Me.CveMoneda > 1 AndAlso UsaComplementaria Then If respuesta AndAlso Me.CveMoneda > 1 AndAlso UsaComplementaria Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, 0, (importeMovimiento * TipoCambio - importeMovimiento).RoundSQL, ConPreP.CveConceptoComplementario, Referencia, Concepto, -1, CveCompra:=Me.CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=Me.CvePersonal, CveCompraAmortizacion:=Me.CveCompraAmortizacion, TipoCambio:=Me.TipoCambio, TipoCambioPago:=1, ImporteME:=ImporteME, CveSubProyecto:=Me.CveSubProyecto) Then If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, (importeMovimiento * Me.TipoCambio - importeMovimiento).RoundSQL, ConPreP.CveConceptoComplementario, Referencia, Concepto, -1, CveCompra:=Me.CveCompra, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=Me.CvePersonal, CveCompraAmortizacion:=Me.CveCompraAmortizacion, TipoCambio:=Me.TipoCambio, TipoCambioPago:=1, ImporteME:=ImporteME, CveSubProyecto:=Me.CveSubProyecto) Then
respuesta = False respuesta = False
End If End If
End If End If
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importeMovimiento, Referencia, ConPreP.CveConcepto, Concepto, Me.Fecha, -1, -1, CveCompra:=CveCompra, CveSubProyecto:=Me.CveSubProyectoPrincipal, CveProveedor:=Me.CveProveedor, CveIE:=Me.CveIE, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=Math.Round(importeMN, 2, MidpointRounding.AwayFromZero), ImporteME:=If(Me.TipoCambio = 1, 0, importeMovimiento), TipoCambio:=Me.TipoCambio, PorcentajeImpuesto:=0, Contabilizable:=True) Then
respuesta = False
End If
End If End If
If DisposeClases Then
If respuesta Then
ObjConta.Commit()
Else
ObjConta.RollBack()
End If
ObjConta.Dispose()
End If
Return respuesta Return respuesta
End Function End Function
End Class End Class