Generar NC En Clientes abonar
This commit is contained in:
@@ -541,7 +541,7 @@ Namespace Modelos
|
||||
|
||||
End Class
|
||||
|
||||
Public Function EmitirFactura(Optional Timbrar As Boolean = True) As MMensajeFactura
|
||||
Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Trasac As SqlClient.SqlTransaction = Nothing, Optional ObjContPaqTransac As ClsContPAQi = Nothing) As MMensajeFactura
|
||||
Dim Retorno As New MMensajeFactura()
|
||||
|
||||
If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then
|
||||
@@ -586,9 +586,16 @@ Namespace Modelos
|
||||
End If
|
||||
|
||||
If Me.CveCliente > 0 Or Me.CveEmpresaCRM > 0 Then
|
||||
If DtDetalle.Rows.Count > 0 Then
|
||||
If DtDetalle.Rows.Count > 0 Then
|
||||
|
||||
Dim ObjVentas As ClsVentas = Nothing
|
||||
If Trasac IsNot Nothing Then
|
||||
ObjVentas = New ClsVentas(Trasac)
|
||||
Else
|
||||
ObjVentas = New ClsVentas()
|
||||
ObjVentas.IniciaTransacSQL()
|
||||
End If
|
||||
|
||||
Dim ObjVentas As New ClsVentas()
|
||||
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
||||
Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
|
||||
Dim ObjContr As New ClsContratos(ObjVentas.IniciaTransacSQL())
|
||||
@@ -604,10 +611,15 @@ Namespace Modelos
|
||||
|
||||
Try
|
||||
'CONTABILIDAD AUTOMATICA Y AC
|
||||
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
|
||||
ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
If ObjContPaqTransac IsNot Nothing Then
|
||||
ObjContPaq = ObjContPaqTransac
|
||||
Else
|
||||
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
|
||||
ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
'GUARDA VENTA
|
||||
Dim TieneAnticipo As Boolean = False
|
||||
Dim CveAnticipoPadre As Integer = 0 ' vinculación con anticipo
|
||||
@@ -787,9 +799,15 @@ Namespace Modelos
|
||||
End If
|
||||
End If
|
||||
|
||||
If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
|
||||
ObjVentas.Commit()
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
||||
If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
|
||||
|
||||
If Trasac Is Nothing Then
|
||||
ObjVentas.Commit()
|
||||
End If
|
||||
If ObjContPaqTransac Is Nothing Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
|
||||
End If
|
||||
|
||||
Try
|
||||
If Not String.IsNullOrEmpty(DirectorioServidor) Then
|
||||
Dim DirectoriArchivoXML As String = System.IO.Path.Combine(DirectorioServidor, "Empresas", UsuarioActual.CveEmpresa.ToString, Me.TipoDocto)
|
||||
@@ -986,42 +1004,61 @@ Namespace Modelos
|
||||
Retorno.Mensajes = ListaMensajes
|
||||
End Try
|
||||
Else
|
||||
ObjVentas.RollBack()
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
If Trasac Is Nothing Then
|
||||
ObjVentas.RollBack()
|
||||
End If
|
||||
If ObjContPaqTransac Is Nothing Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
End If
|
||||
Retorno.Mensajes = ErrorList
|
||||
Retorno.TieneError = True
|
||||
End If
|
||||
|
||||
Else
|
||||
ObjVentas.RollBack()
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
If Trasac Is Nothing Then
|
||||
ObjVentas.RollBack()
|
||||
End If
|
||||
|
||||
If ObjContPaqTransac Is Nothing Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
End If
|
||||
|
||||
ErrorList.Add("Ocurrió un error al procesar los datos. Por favor rectifique y vuelta a intentar.")
|
||||
Retorno.Mensajes = ErrorList
|
||||
Retorno.TieneError = True
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Me.ErrorList.Add(ex.ToString())
|
||||
ObjVentas.RollBack()
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
|
||||
If Trasac Is Nothing Then
|
||||
ObjVentas.RollBack()
|
||||
End If
|
||||
If ObjContPaqTransac Is Nothing Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
End If
|
||||
|
||||
Retorno.Mensajes = ErrorList
|
||||
Retorno.TieneError = True
|
||||
Finally
|
||||
ObjVentas.Dispose()
|
||||
ObjConta.Dispose()
|
||||
ObjInventario.Dispose()
|
||||
ObjCGame.Dispose()
|
||||
ObjContr.Dispose()
|
||||
ObjDocCliente.Dispose()
|
||||
ObjClientes.Dispose()
|
||||
ObjAcum.Dispose()
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose()
|
||||
If Trasac Is Nothing Then
|
||||
ObjVentas.Dispose()
|
||||
ObjConta.Dispose()
|
||||
ObjInventario.Dispose()
|
||||
ObjCGame.Dispose()
|
||||
ObjContr.Dispose()
|
||||
ObjDocCliente.Dispose()
|
||||
ObjClientes.Dispose()
|
||||
ObjAcum.Dispose()
|
||||
End If
|
||||
If ObjContPaqTransac Is Nothing Then
|
||||
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
|
||||
End If
|
||||
End Try
|
||||
Else
|
||||
Retorno.Mensajes.Add("No se han agregado productos/servicios")
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
@@ -5086,7 +5123,8 @@ Namespace Modelos
|
||||
Public Property CveAlmacenRecepcionUsados As Integer = -1
|
||||
Public Property CveDireccionEnvio As Integer
|
||||
Public Property RefacturacionGeneroNC As Boolean = False
|
||||
Public Property Pagado As Decimal
|
||||
Public Property Pagado As Decimal
|
||||
Public Property DescuentoProntoPago As Decimal
|
||||
'Public Property Sucursal As SucursalModel
|
||||
Public Property SubProyecto As Modelos.SubProyectoModel
|
||||
|
||||
|
||||
@@ -13638,19 +13638,32 @@ Partial Class Compras_Compras
|
||||
End Sub
|
||||
|
||||
Private Sub VinculaDevolucion()
|
||||
'Borramos el TmpDT
|
||||
TmpDT.Clear()
|
||||
'LIMPIAR PARTIDAS DE LA COMPRA PARA AGREGAR NUEVAS
|
||||
TmpDT.Clear()
|
||||
|
||||
Dim SubTotalCompra As Decimal = TxtSubTotal.Text.ToDecimal()
|
||||
Dim TotalCompra As Decimal = TxtTotal.Text.ToDecimal()
|
||||
Dim IVACompra As Decimal = TxtIVA.Text.ToDecimal()
|
||||
Dim IEPSCompra As Decimal = TxtIEPS.Text.ToDecimal()
|
||||
Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal()
|
||||
Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal()
|
||||
|
||||
'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra
|
||||
|
||||
Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2)
|
||||
|
||||
'Iteramos el GridView de la OC
|
||||
For Each gvr As GridViewRow In GVDevolucion.Rows
|
||||
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
|
||||
|
||||
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
|
||||
|
||||
Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero
|
||||
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0)
|
||||
|
||||
Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal
|
||||
Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero
|
||||
Dim UM As String = gvr.DataKey("UM").ToString
|
||||
Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero
|
||||
Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString
|
||||
Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero
|
||||
Dim PS As String = gvr.DataKey("PS").ToString
|
||||
Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero
|
||||
Dim CveSubProyectoContrato As String = "-1"
|
||||
@@ -13660,7 +13673,7 @@ Partial Class Compras_Compras
|
||||
Dim Obs As String = ""
|
||||
Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal
|
||||
Dim Total As Decimal = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal
|
||||
Dim IVA As Decimal = 0
|
||||
Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2)
|
||||
Dim Descuento As Decimal = 0
|
||||
|
||||
AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False)
|
||||
@@ -17531,15 +17544,17 @@ Partial Class Compras_Compras
|
||||
TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Obs") = TxtPSAlias.Text.Trim
|
||||
|
||||
'busco si el producto está en otros renglones QUE NO LO TENGAN ASIGNADO, LO VINCULE
|
||||
For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0")
|
||||
drt("CvePS") = CvePS
|
||||
drt("PS") = tPS
|
||||
drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero
|
||||
drt("UM") = DdlUnidadAlias.SelectedItem.Text
|
||||
drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero
|
||||
drt("Clasificacion") = HdnPSAliasClasificacion.Value
|
||||
drt("Obs") = TxtPSAlias.Text.Trim
|
||||
Next
|
||||
If UsuarioActual.CveEmpresa <> 141 Then
|
||||
For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0")
|
||||
drt("CvePS") = CvePS
|
||||
drt("PS") = tPS
|
||||
drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero
|
||||
drt("UM") = DdlUnidadAlias.SelectedItem.Text
|
||||
drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero
|
||||
drt("Clasificacion") = HdnPSAliasClasificacion.Value
|
||||
drt("Obs") = TxtPSAlias.Text.Trim
|
||||
Next
|
||||
End If
|
||||
|
||||
TmpDT.AcceptChanges()
|
||||
|
||||
|
||||
@@ -2621,7 +2621,7 @@
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>IVA (16%):</Value>
|
||||
<Value>IVA</Value>
|
||||
<Style>
|
||||
<FontFamily>calibri</FontFamily>
|
||||
<FontSize>9pt</FontSize>
|
||||
|
||||
@@ -837,19 +837,22 @@
|
||||
<i></i>
|
||||
</div>
|
||||
<div id="DivRetenciones" runat="server">
|
||||
<div id="DivTipoRetenciones" runat="server" visible="false" class="form-group form-md-line-input input-iconright">
|
||||
<asp:DropDownList ID="DdlTipoRetencion" AutoPostBack="true" OnSelectedIndexChanged="DdlTipoRetencion_SelectedIndexChanged" CssClass="form-control select2me" runat="server" AppendDataBoundItems="true" CausesValidation="true">
|
||||
<asp:ListItem Selected="True" Text="Sin Retención" Value="0"></asp:ListItem>
|
||||
<asp:ListItem Text="Arrendamiento" Value="1"></asp:ListItem>
|
||||
<asp:ListItem Text="Servicios Profesionales" Value="2"></asp:ListItem>
|
||||
<asp:ListItem Text="Fletes" Value="3"></asp:ListItem>
|
||||
<asp:ListItem Text="Servicios" Value="4"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
<label for="<%= DdlTipoRetencion.ClientID.ToString()%>">Tipo de Retención de IVA:</label>
|
||||
<asp:RequiredFieldValidator ID="RFVTipoRetencion" runat="server" ControlToValidate="DdlTipoRetencion" CssClass="help-block" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Tipo de Retención''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
|
||||
<i></i>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div id="DivTipoRetenciones" runat="server" visible="false" class="form-group form-md-line-input input-iconright">
|
||||
<asp:DropDownList ID="DdlTipoRetencion" ToolTip="Al establecer la retención de servicios, deberá especificarse el producto, como outsourcing para que se aplique la retención."
|
||||
AutoPostBack="true" OnSelectedIndexChanged="DdlTipoRetencion_SelectedIndexChanged" CssClass="form-control select2me" runat="server" AppendDataBoundItems="true" CausesValidation="true">
|
||||
<asp:ListItem Selected="True" Text="Sin Retención" Value="0"></asp:ListItem>
|
||||
<asp:ListItem Text="Arrendamiento" Value="1"></asp:ListItem>
|
||||
<asp:ListItem Text="Servicios Profesionales" Value="2"></asp:ListItem>
|
||||
<asp:ListItem Text="Fletes" Value="3"></asp:ListItem>
|
||||
<asp:ListItem Text="Servicios" Value="4"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
<label for="<%= DdlTipoRetencion.ClientID.ToString()%>" >Tipo de Retención de IVA:</label>
|
||||
<asp:RequiredFieldValidator ID="RFVTipoRetencion" runat="server" ControlToValidate="DdlTipoRetencion" CssClass="help-block" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Tipo de Retención''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
|
||||
<i></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div id="DivRetIVA" runat="server" class="form-group form-md-line-input input-iconright">
|
||||
<asp:TextBox ID="TxtRetIVA" CssClass="form-control" runat="server" MaxLength="9" Text="0"></asp:TextBox>
|
||||
@@ -859,6 +862,8 @@
|
||||
<i style="font-weight: bold;">%</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group form-md-line-input input-iconright">
|
||||
<asp:TextBox ID="TxtRetISR" CssClass="form-control" runat="server" MaxLength="9" Text="0"></asp:TextBox>
|
||||
@@ -868,6 +873,8 @@
|
||||
<i style="font-weight: bold;">%</i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group form-md-line-input" id="DivRetFletes" runat="server" visible="false">
|
||||
|
||||
@@ -344,6 +344,11 @@
|
||||
<asp:Literal ID="LtlDescuentoProntoPago" runat="server" Text='<%# Eval("DescuentoProntoPago", "{0:N2}") %>'></asp:Literal>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField HeaderText="Generar NC" Visible="false" >
|
||||
<ItemTemplate>
|
||||
<asp:CheckBox ID="ChkGenerarNC" CssClass="chkgv" runat="server" Visible="false"></asp:CheckBox>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField ItemStyle-Width="300px">
|
||||
<HeaderTemplate>Auxiliar</HeaderTemplate>
|
||||
<ItemTemplate>
|
||||
@@ -506,6 +511,11 @@
|
||||
} else {
|
||||
txt.value = "";
|
||||
}
|
||||
//if (typeof t2 === "undefined") {
|
||||
|
||||
//} else {
|
||||
|
||||
//}
|
||||
|
||||
|
||||
if (chkPesosBancos) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Imports System.Linq
|
||||
|
||||
Partial Class Ventas_ClientesAbonar
|
||||
Inherits ClsPaginas
|
||||
|
||||
@@ -459,7 +461,10 @@ Partial Class Ventas_ClientesAbonar
|
||||
TxtImporte.Text = ""
|
||||
TxtObservaciones.Text = ""
|
||||
If SumDescuentoProntoPago > 0.0 Then
|
||||
GvCxC.Columns(14).Visible = True
|
||||
GvCxC.Columns(14).Visible = True 'MOSTRAR DESCUENTO PRONTO PAGO
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||
GvCxC.Columns(15).Visible = True 'HABILITAR NC
|
||||
End If
|
||||
End If
|
||||
|
||||
Mov.Dispose()
|
||||
@@ -635,6 +640,11 @@ Partial Class Ventas_ClientesAbonar
|
||||
e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00
|
||||
e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo")
|
||||
End If
|
||||
|
||||
If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() >= 0 Then
|
||||
e.Row.FCCheckBox("ChkGenerarNC").Visible = True
|
||||
End If
|
||||
|
||||
Else
|
||||
e.Row.FCTextBox("TxtAbonar").Visible = False
|
||||
e.Row.FCTextBox("TxtComision").Visible = False
|
||||
@@ -680,6 +690,8 @@ Partial Class Ventas_ClientesAbonar
|
||||
Next
|
||||
|
||||
Dim MsgError As String = ""
|
||||
Dim NCGeneradas As New List(Of Modelos.Factura.MMensajeFactura)
|
||||
Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura)
|
||||
|
||||
'comentada RMF 2018.09.28
|
||||
'Dim Dep As New ClsGenerales
|
||||
@@ -1362,43 +1374,43 @@ Partial Class Ventas_ClientesAbonar
|
||||
|
||||
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
End If
|
||||
'Case 92
|
||||
' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar
|
||||
' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
||||
' importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
|
||||
' CveSubProyectoContabilizar = CveSubProyecto
|
||||
|
||||
' If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
' 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
|
||||
' If gvr.DataKey("CveMoneda").ToEntero <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
|
||||
' importeMX = ImporteMovimiento
|
||||
' IdCtaContable = IdCtaContMonedaExtranjera
|
||||
' Else
|
||||
' IdCtaContable = IdCuentaCliente
|
||||
' CveCuenta = CveCuentaCliente
|
||||
' End If
|
||||
|
||||
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=importeMX, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
' MsgError = "No se pudo insertar la póliza"
|
||||
' End If
|
||||
|
||||
' If gvr.DataKey("CveMoneda").ToEntero = 2 Then
|
||||
' IdCtaContable = IdCtaContComplementaria
|
||||
' CveCuenta = CveCuentaComplementaria
|
||||
' If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
|
||||
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 227, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then
|
||||
' MsgError = "No se pudo insertar la póliza"
|
||||
' End If
|
||||
' importeMX = ImporteMovimiento
|
||||
' IdCtaContable = IdCtaContMonedaExtranjera
|
||||
' CveCuenta = CveCuentaMonedaExtranjera
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' End If
|
||||
' ImporteMovimiento = 0
|
||||
End If
|
||||
'Case 92
|
||||
' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar
|
||||
' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
|
||||
' importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
|
||||
' CveSubProyectoContabilizar = CveSubProyecto
|
||||
|
||||
' If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
|
||||
|
||||
' 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
|
||||
' If gvr.DataKey("CveMoneda").ToEntero <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
|
||||
' importeMX = ImporteMovimiento
|
||||
' IdCtaContable = IdCtaContMonedaExtranjera
|
||||
' Else
|
||||
' IdCtaContable = IdCuentaCliente
|
||||
' CveCuenta = CveCuentaCliente
|
||||
' End If
|
||||
|
||||
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=importeMX, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then
|
||||
' MsgError = "No se pudo insertar la póliza"
|
||||
' End If
|
||||
|
||||
' If gvr.DataKey("CveMoneda").ToEntero = 2 Then
|
||||
' IdCtaContable = IdCtaContComplementaria
|
||||
' CveCuenta = CveCuentaComplementaria
|
||||
' If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
|
||||
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 227, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then
|
||||
' MsgError = "No se pudo insertar la póliza"
|
||||
' End If
|
||||
' importeMX = ImporteMovimiento
|
||||
' IdCtaContable = IdCtaContMonedaExtranjera
|
||||
' CveCuenta = CveCuentaMonedaExtranjera
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' End If
|
||||
' ImporteMovimiento = 0
|
||||
Case 134 'Pago Intermediario
|
||||
If RblTipoPago.SelectedValue = "2" Then
|
||||
ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - gvr.FCTextBox("TxtComision").Text.ToDecimal
|
||||
@@ -1438,6 +1450,10 @@ Partial Class Ventas_ClientesAbonar
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
If gvr.FCCheckBox("ChkGenerarNC").Checked Then
|
||||
ListaFacturasGenerarNC.Add(New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) With {.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()})
|
||||
End If
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
@@ -1565,7 +1581,16 @@ Partial Class Ventas_ClientesAbonar
|
||||
MsgError = "No se insertó el encabezado"
|
||||
End If
|
||||
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
|
||||
If MsgError = "" Then
|
||||
Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaFacturasGenerarNC)
|
||||
If Resp.CveVenta > 0 Then
|
||||
NCGeneradas.Add(Resp)
|
||||
Else
|
||||
MsgError = "No se pudo generar la nota de credito"
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
If MsgError = "" Then
|
||||
'se agregan las pólizas de Armonización Contable
|
||||
@@ -1649,8 +1674,17 @@ Partial Class Ventas_ClientesAbonar
|
||||
|
||||
|
||||
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
|
||||
Dim SbMensaje As New StringBuilder
|
||||
SbMensaje.Append(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
|
||||
|
||||
For Each NC In NCGeneradas
|
||||
For Each msg In NC.Mensajes
|
||||
SbMensaje.Append(msg)
|
||||
Next
|
||||
SbMensaje.Append("</br>")
|
||||
Next
|
||||
|
||||
Alert(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago), TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
|
||||
Alert(SbMensaje.ToString())
|
||||
Else
|
||||
ObjIE.RollBack()
|
||||
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
||||
@@ -1671,7 +1705,17 @@ Partial Class Ventas_ClientesAbonar
|
||||
|
||||
If IDPoliza > 0 Then StrMsg.AppendFormat("<br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a>", IDPoliza, FolioPoliza)
|
||||
|
||||
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
|
||||
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
|
||||
|
||||
Dim SbMensaje As New StringBuilder
|
||||
SbMensaje.Append(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
|
||||
|
||||
For Each NC In NCGeneradas
|
||||
For Each msg In NC.Mensajes
|
||||
StrMsg.Append(msg)
|
||||
Next
|
||||
StrMsg.Append("</br>")
|
||||
Next
|
||||
|
||||
Alert($"{StrMsg.ToString}<br/><br/>{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
|
||||
End If
|
||||
@@ -1703,8 +1747,463 @@ Partial Class Ventas_ClientesAbonar
|
||||
ObjEvento.Dispose()
|
||||
LimpiaCampos()
|
||||
|
||||
End Sub
|
||||
End Sub
|
||||
|
||||
#Region " N O T A - D E - C R E D I T O"
|
||||
|
||||
Private Function GenerarNC(Trasac As SqlClient.SqlTransaction, ObjConta As ClsContPAQi, ListaVentasGenerarNC As List(Of Modelos.Factura)) As Modelos.Factura.MMensajeFactura
|
||||
Dim ObjFacturaDevolucion = New Modelos.Factura(UsuarioActual)
|
||||
ObjFacturaDevolucion.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML
|
||||
ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
|
||||
ObjFacturaDevolucion.UsuarioCreo = UsuarioActual.Usuario
|
||||
|
||||
'If CveVentaPadre > 0 Then
|
||||
' ObjFacturaDevolucion.CveVentaPadre = CveVentaPadre
|
||||
' ObjFacturaDevolucion.CveVentaRelacion = CveVentaPadre
|
||||
'End If
|
||||
|
||||
Dim Folio As String = ""
|
||||
Dim Serie As String = ""
|
||||
|
||||
Dim ObjFolios As New ClsGralFolios()
|
||||
If ObjFolios.GetFolios("Egs", UsuarioActual.CveEmpresa) Then
|
||||
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo' AND CveSubProyecto = {0}", Me.CveSubProyecto))
|
||||
If DT.Rows.Count > 0 Then
|
||||
Serie = DT.Rows(0)("Serie").ToString()
|
||||
Folio = DT.Rows(0)("FActual").ToString()
|
||||
End If
|
||||
DT.Dispose()
|
||||
End If
|
||||
ObjFolios.Dispose()
|
||||
|
||||
ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa
|
||||
ObjFacturaDevolucion.TipoCambio = If(Me.CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal())
|
||||
ObjFacturaDevolucion.ConvertirPesos = False
|
||||
ObjFacturaDevolucion.CveMoneda = Me.CveMoneda
|
||||
ObjFacturaDevolucion.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {Me.CveMoneda}")
|
||||
ObjFacturaDevolucion.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {Me.CveMoneda}")
|
||||
ObjFacturaDevolucion.Serie = Serie
|
||||
ObjFacturaDevolucion.Folio = Folio
|
||||
ObjFacturaDevolucion.Fecha = Now
|
||||
ObjFacturaDevolucion.CvePrePoliza = -1
|
||||
ObjFacturaDevolucion.CveMetodoPago = 0
|
||||
ObjFacturaDevolucion.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR)
|
||||
ObjFacturaDevolucion.FormaPago = 0
|
||||
|
||||
ObjFacturaDevolucion.TipoDocto = "Egs"
|
||||
ObjFacturaDevolucion.Fecha = Now
|
||||
|
||||
ObjFacturaDevolucion.Version = "3.3"
|
||||
ObjFacturaDevolucion.CveMetodoPago33 = 1
|
||||
ObjFacturaDevolucion.MetodoPago33 = "Pago en una sola exhibición"
|
||||
ObjFacturaDevolucion.ClaveMetodoPagoSAT = "PUE"
|
||||
|
||||
ObjFacturaDevolucion.CveFormaPago33 = 21
|
||||
ObjFacturaDevolucion.FormaPago33 = "Aplicación de anticipos"
|
||||
ObjFacturaDevolucion.FormaPagoSAT33 = "30"
|
||||
|
||||
ObjFacturaDevolucion.MetodoPago = ""
|
||||
ObjFacturaDevolucion.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {ObjFacturaDevolucion.CveMetodoPago33}")
|
||||
|
||||
ObjFacturaDevolucion.CveSubProyecto = Me.CveSubProyecto
|
||||
ObjFacturaDevolucion.SetSubProyecto()
|
||||
|
||||
ObjFacturaDevolucion.CveCliente = Me.CveCliente
|
||||
ObjFacturaDevolucion.SetCliente()
|
||||
|
||||
Dim ObjCliente As New ClsClientes
|
||||
If ObjCliente.GetClientes(ObjFacturaDevolucion.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
|
||||
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||
|
||||
ObjFacturaDevolucion.CveUsoCFDI = ObjCliente.CveUsoCFDI
|
||||
ObjFacturaDevolucion.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
|
||||
ObjFacturaDevolucion.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
|
||||
|
||||
ObjFacturaDevolucion.DtDetalle = CreaDTDetalleNC()
|
||||
|
||||
CargaImpuestos(ObjFacturaDevolucion, ListaVentasGenerarNC, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA, ObjCliente.RetISR)
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjCliente.GetSucursales(CveCliente) Then
|
||||
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
||||
ObjFacturaDevolucion.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
|
||||
Else
|
||||
ObjFacturaDevolucion.CveClienteSucursal = -1
|
||||
End If
|
||||
End If
|
||||
ObjCliente.Dispose()
|
||||
|
||||
ObjFacturaDevolucion.CveTipoRelacion = 7
|
||||
ObjFacturaDevolucion.TipoRelacion = "07"
|
||||
|
||||
Dim Fol As New List(Of String)
|
||||
For Each Fac In ListaVentasGenerarNC
|
||||
Fol.Add(Fac.FolioFiscal)
|
||||
Next
|
||||
ObjFacturaDevolucion.UUIDRelacionados = Fol
|
||||
|
||||
Select Case ObjFacturaDevolucion.TipoDocto
|
||||
Case "Ing"
|
||||
ObjFacturaDevolucion.TipoDocumento = "Factura"
|
||||
Case "REM"
|
||||
ObjFacturaDevolucion.TipoDocumento = "Remision"
|
||||
Case "Cot"
|
||||
ObjFacturaDevolucion.TipoDocumento = "Cotizacion"
|
||||
Case "Egs"
|
||||
ObjFacturaDevolucion.TipoDocumento = "Nota de Crédito"
|
||||
Case "Dev"
|
||||
ObjFacturaDevolucion.TipoDocumento = "Nota de Devolución"
|
||||
Case Else
|
||||
ObjFacturaDevolucion.TipoDocumento = ""
|
||||
End Select
|
||||
|
||||
If ObjFacturaDevolucion.TipoDocto IsNot Nothing Then
|
||||
ViewState("TipoDoctoDevolucion") = ObjFacturaDevolucion.TipoDocto
|
||||
End If
|
||||
|
||||
ObjFacturaDevolucion.FechaPago = Now
|
||||
|
||||
ObjFacturaDevolucion.CveCorte = -1
|
||||
ObjFacturaDevolucion.CveMesa = -1
|
||||
ObjFacturaDevolucion.NumeroPersonas = 0
|
||||
ObjFacturaDevolucion.CveContrato = -1
|
||||
ObjFacturaDevolucion.DescripcionContrato = ""
|
||||
ObjFacturaDevolucion.CveClienteSucursal = -1
|
||||
ObjFacturaDevolucion.Entrega = ""
|
||||
ObjFacturaDevolucion.CveAlmacen = -1
|
||||
|
||||
Dim DtVentasNC = InicializaDTVentasNC()
|
||||
|
||||
Dim TotalImporte As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("TotalImporte").ToDecimal()
|
||||
Dim ImporteIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIVA").ToDecimal()
|
||||
Dim ImporteRetIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetIVA").ToDecimal()
|
||||
Dim ImporteRetISR As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetISR").ToDecimal()
|
||||
Dim ImporteIEPS As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIEPS").ToDecimal()
|
||||
Dim Descuento As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("Descuento").ToDecimal()
|
||||
Dim Amortizacion As Decimal = 0
|
||||
|
||||
Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
|
||||
|
||||
'DETALLES
|
||||
ObjFacturaDevolucion.SubTotal = TotalImporte
|
||||
ObjFacturaDevolucion.Descuento = Descuento
|
||||
ObjFacturaDevolucion.Amortizacion = Amortizacion
|
||||
ObjFacturaDevolucion.IVA = ImporteIVA
|
||||
ObjFacturaDevolucion.RetIVA = ImporteRetIVA
|
||||
ObjFacturaDevolucion.RetISR = ImporteRetISR
|
||||
ObjFacturaDevolucion.IEPS = ImporteIEPS
|
||||
ObjFacturaDevolucion.Total = Total
|
||||
ObjFacturaDevolucion.TotalOtrosConceptos = 0
|
||||
|
||||
For Each Fac In ListaVentasGenerarNC
|
||||
Dim Drt = DtVentasNC.NewRow
|
||||
Drt("CveVenta") = Fac.CveVenta
|
||||
Drt("Importe") = Fac.DescuentoProntoPago
|
||||
Drt("FolioFiscal") = Fac.FolioFiscal
|
||||
DtVentasNC.Rows.Add(Drt)
|
||||
Next
|
||||
|
||||
DtVentasNC.AcceptChanges()
|
||||
|
||||
ObjFacturaDevolucion.DtVentasNC = DtVentasNC
|
||||
|
||||
Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Trasac:=Trasac, ObjContPaqTransac:=ObjConta)
|
||||
Return Resp
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub AgregaTempDTNC(ByRef TmpDT As DataTable, CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String,
|
||||
CveClasificacion As Integer, Clasificacion As String, CveProyecto As Integer, CveSubProyecto As Integer,
|
||||
Obs As String, Cantidad As Double, PU As Double, PorcentajeIVA As Double, ImporteIVA As Double, PorcentajeRetIVA As Double, ImporteRetIVA As Double,
|
||||
PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double,
|
||||
Total As Double, SerieLote As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String,
|
||||
SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer,
|
||||
CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer)
|
||||
|
||||
Dim Row As DataRow = Nothing
|
||||
Row = TmpDT.NewRow()
|
||||
|
||||
Row("Consec") = TmpDT.Rows.Count + 1
|
||||
Row("Orden") = TmpDT.Rows.Count + 1
|
||||
|
||||
Row("CvePS") = CvePS
|
||||
Row("PS") = PS
|
||||
Row("Codigo") = Codigo
|
||||
Row("CodigoPS") = CodigoPS
|
||||
Row("CveTipoPS") = CveTipoPS
|
||||
Row("CveTipoInvPS") = CveTipoInvPS
|
||||
|
||||
Row("CveUM") = CveUM
|
||||
Row("UM") = UM
|
||||
|
||||
Row("CveClasificacion") = CveClasificacion
|
||||
Row("Clasificacion") = Clasificacion
|
||||
Row("CveProyecto") = CveProyecto
|
||||
Row("Proyecto") = ""
|
||||
Row("CveSubProyecto") = CveSubProyecto
|
||||
Row("SubProyecto") = ""
|
||||
|
||||
Row("Obs") = Obs
|
||||
Row("Cantidad") = Cantidad
|
||||
Row("PU") = Math.Round(PU, 6)
|
||||
Row("PorcentajeIVA") = PorcentajeIVA
|
||||
Row("IVA") = PorcentajeIVA
|
||||
Row("ImporteIVA") = Math.Round(ImporteIVA, 2)
|
||||
Row("PorcentajeRetIVA") = PorcentajeRetIVA
|
||||
Row("ImporteRetIVA") = Math.Round(ImporteRetIVA, 2)
|
||||
Row("PorcentajeRetISR") = PorcentajeRetISR
|
||||
Row("ImporteRetISR") = Math.Round(ImporteRetISR, 2)
|
||||
Row("PorcentajeIEPS") = PorcentajeIEPS
|
||||
Row("ImporteIEPS") = Math.Round(ImporteIEPS, 2)
|
||||
Row("IEPS") = Math.Round(ImporteIEPS, 2)
|
||||
Row("TipoDescuento") = TipoDescuento
|
||||
Row("Descuento") = Math.Round(Descuento, 2)
|
||||
Row("Total") = Math.Round(Total, 2)
|
||||
Row("TotalImporte") = Math.Round(Total, 2)
|
||||
|
||||
Row("SerieLote") = SerieLote
|
||||
Row("TiempoEntrega") = TiempoEntrega
|
||||
Row("CvePresupuestoIngreso") = CvePresupuestoIngreso
|
||||
Row("EntregaDirecta") = EntregaDirecta
|
||||
Row("SATClaveProdServ") = SATClaveProdServ
|
||||
Row("SATClaveUM") = SATClaveUM
|
||||
|
||||
'Contratos
|
||||
Row("CveContratoDetalle") = CveContratoDetalle
|
||||
Row("CveVentaDetalle") = CveVentaDetalle
|
||||
Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
|
||||
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
||||
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
|
||||
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
|
||||
|
||||
TmpDT.Rows.Add(Row)
|
||||
End Sub
|
||||
|
||||
Private Sub CargaImpuestos(ByRef ObjFacturaDevolucion As Modelos.Factura, ListaVentasGenerarNC As List(Of Modelos.Factura), ClienteDesglosaIEPS As Boolean, ClienteRetIVA As Decimal, ClienteRetISR As Decimal)
|
||||
Dim DtImpuestos As New DataTable
|
||||
DtImpuestos.Columns.Add("ImportePU", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("ImporteTotal", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("ImporteIVA", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("ImporteRetISR", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("ImporteIEPS", GetType(Decimal))
|
||||
DtImpuestos.Columns.Add("CveSubProyecto", GetType(Integer))
|
||||
DtImpuestos.AcceptChanges()
|
||||
Dim AcumuladoNC As Decimal = 0
|
||||
|
||||
For Each Fac In ListaVentasGenerarNC
|
||||
DtImpuestos.Merge(CargaDtImpuestosNC(Fac.CveVenta, Fac.DescuentoProntoPago), True, MissingSchemaAction.Ignore)
|
||||
Next
|
||||
|
||||
DtImpuestos = CargaTotalesImpuestos(DtImpuestos)
|
||||
|
||||
Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, ObjFacturaDevolucion.CveSubProyecto).Rows(0)
|
||||
|
||||
Dim Cantidad As Decimal = 1
|
||||
Dim CveProyecto As Integer = DrSubProyecto("CveProyecto").ToString().ToEntero()
|
||||
Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero
|
||||
Dim SubProyecto = DrSubProyecto("SubProyecto").ToString
|
||||
Dim Proyecto = DrSubProyecto("Proyecto").ToString
|
||||
|
||||
Dim CveSATNC = "84111506"
|
||||
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("")
|
||||
|
||||
For Each Dr As DataRow In DtImpuestos.Rows
|
||||
AgregaTempDTNC(ObjFacturaDevolucion.DtDetalle, DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero,
|
||||
DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, CveSubProyecto,
|
||||
"", Cantidad, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal,
|
||||
Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1,
|
||||
DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable
|
||||
Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
|
||||
|
||||
Dim TmpDT As DataTable = Nothing
|
||||
Dim ObjVentas As New ClsVentas
|
||||
|
||||
If ObjVentas.GetVentaDetalle(CveVentaNC) Then
|
||||
TmpDT = ObjVentas.DtResultados
|
||||
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||
End If
|
||||
|
||||
If ObjVentas.GetVenta(CveVentaNC, UsuarioActual.CveEmpresa) Then
|
||||
If ObjVentas.DtResultados.Rows.Count > 0 Then
|
||||
Total = ObjVentas.DtResultados()(0)("Total").ToString.ToDecimal
|
||||
SubTotal = ObjVentas.DtResultados()(0)("SubTotal").ToString.ToDecimal
|
||||
End If
|
||||
End If
|
||||
ObjVentas.Dispose()
|
||||
|
||||
Dim DtImpuestosLocal = TmpDT.FiltraParametros("", "", {"PorcentajeIVA", "PorcentajeRetIVA", "PorcentajeRetISR", "PorcentajeIEPS", "CveSubProyecto"}).Copy
|
||||
DtImpuestosLocal.Columns.Add("ImportePU", GetType(Decimal))
|
||||
DtImpuestosLocal.Columns.Add("ImporteTotal", GetType(Decimal))
|
||||
DtImpuestosLocal.Columns.Add("ImporteIVA", GetType(Decimal))
|
||||
DtImpuestosLocal.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
||||
DtImpuestosLocal.Columns.Add("ImporteRetISR", GetType(Decimal))
|
||||
DtImpuestosLocal.Columns.Add("ImporteIEPS", GetType(Decimal))
|
||||
|
||||
Dim ImporteReferencia As Decimal = Total
|
||||
Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
|
||||
Dim FiltroStr As String = ""
|
||||
For Each Dr As DataRow In DtImpuestosLocal.Rows
|
||||
FiltroStr = String.Format("ISNULL(PorcentajeIVA,0) = {0} AND ISNULL(PorcentajeRetIVA,0) = {1} AND ISNULL(PorcentajeRetISR,0) = {2} AND ISNULL(PorcentajeIEPS,0) = {3} AND ISNULL(CveSubProyecto,0) = {4} ", Dr("PorcentajeIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("CveSubProyecto"))
|
||||
Dr("ImporteTotal") = Math.Round(Porcentaje * (TmpDT.SUM("TotalImporte", FiltroStr) - TmpDT.SUM("Descuento", FiltroStr)), 2)
|
||||
|
||||
Dr("ImporteIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
|
||||
Dr("ImporteRetIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
|
||||
Dr("ImporteRetISR") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
|
||||
Dr("ImporteIEPS") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2)
|
||||
|
||||
'Dr("ImporteIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr), 2)
|
||||
'Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2)
|
||||
'Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2)
|
||||
'Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2)
|
||||
|
||||
Dr("ImportePU") = Dr("ImporteTotal").ToString.ToDecimal '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
|
||||
Next
|
||||
'codigo para ajuste de centavo, si el importe total no cuadra con los totales
|
||||
Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
|
||||
If Math.Abs(difTmp) >= 0.01 Then
|
||||
'asusto la diferencia en el último concepto
|
||||
Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp
|
||||
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = ImporteAjustado
|
||||
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImportePU") = ImporteAjustado
|
||||
End If
|
||||
'CARGA FACTURA A LA CUAL SE APLICA LA NC
|
||||
'CargaNCDT(CveVentaNC, Importe.ToDecimal)
|
||||
Return DtImpuestosLocal
|
||||
End Function
|
||||
|
||||
Private Function CargaTotalesImpuestos(DtImpuestos As DataTable) As DataTable
|
||||
Dim query = From dr In DtImpuestos
|
||||
Group By PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal,
|
||||
PorcentajeRetIVA = dr("PorcentajeRetIVA").ToString.ToDecimal,
|
||||
PorcentajeRetISR = dr("PorcentajeRetISR").ToString.ToDecimal,
|
||||
PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal
|
||||
Into x = Group
|
||||
Select ImportePU = x.Sum(Function(s) s("ImportePU").ToString.ToDecimal),
|
||||
ImporteTotal = x.Sum(Function(s) s("ImporteTotal").ToString.ToDecimal),
|
||||
ImporteIVA = x.Sum(Function(s) Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)), ' Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)) * (1 + PorcentajeIEPS) * PorcentajeIVA,
|
||||
ImporteRetIVA = x.Sum(Function(s) Math.Round(s("ImporteRetIVA").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetIVA,
|
||||
ImporteRetISR = x.Sum(Function(s) Math.Round(s("ImporteRetISR").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetISR,
|
||||
ImporteIEPS = x.Sum(Function(s) Math.Round(s("ImporteIEPS").ToString.ToDecimal, 2)), 'Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeIEPS,
|
||||
PorcentajeIVA = PorcentajeIVA,
|
||||
PorcentajeRetIVA = PorcentajeRetIVA,
|
||||
PorcentajeRetISR = PorcentajeRetISR,
|
||||
PorcentajeIEPS = PorcentajeIEPS
|
||||
|
||||
Return query.QueryToDataTable(False)
|
||||
End Function
|
||||
|
||||
Protected Function CreaDTDetalleNC() As DataTable
|
||||
Dim TmpDT = New DataTable
|
||||
TmpDT.Columns.Add("CveVenta", GetType(Integer))
|
||||
TmpDT.Columns.Add("Consec", GetType(Integer))
|
||||
TmpDT.Columns.Add("Cantidad", GetType(Decimal))
|
||||
TmpDT.Columns.Add("Codigo", GetType(String))
|
||||
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
||||
TmpDT.Columns.Add("UM", GetType(String))
|
||||
TmpDT.Columns.Add("SATClaveUM", GetType(String))
|
||||
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
||||
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
||||
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
||||
TmpDT.Columns.Add("PS", GetType(String))
|
||||
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
||||
TmpDT.Columns.Add("SATClaveProdServ", GetType(String))
|
||||
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
||||
TmpDT.Columns.Add("CveTipoPS", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer))
|
||||
TmpDT.Columns.Add("SerieLote", GetType(String))
|
||||
TmpDT.Columns.Add("CuentaPredial", GetType(String))
|
||||
TmpDT.Columns.Add("Obs", GetType(String))
|
||||
TmpDT.Columns.Add("TiempoEntrega", GetType(String))
|
||||
TmpDT.Columns.Add("PU", GetType(Decimal))
|
||||
TmpDT.Columns.Add("IVA", GetType(Decimal))
|
||||
TmpDT.Columns.Add("ImporteIVA", GetType(Decimal))
|
||||
TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal))
|
||||
TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal))
|
||||
TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal))
|
||||
TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
|
||||
TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal))
|
||||
TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal))
|
||||
TmpDT.Columns.Add("IEPS", GetType(Decimal))
|
||||
TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal))
|
||||
TmpDT.Columns.Add("Descuento", GetType(Decimal))
|
||||
TmpDT.Columns.Add("TipoDescuento", GetType(Integer))
|
||||
TmpDT.Columns.Add("TotalImporte", GetType(Decimal))
|
||||
TmpDT.Columns.Add("Total", GetType(Decimal))
|
||||
'Para uso del módulo contable
|
||||
TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer))
|
||||
TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer))
|
||||
TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean))
|
||||
TmpDT.Columns.Add("CveProyecto", GetType(Integer))
|
||||
TmpDT.Columns.Add("Proyecto", GetType(String))
|
||||
TmpDT.Columns.Add("CveSubProyecto", GetType(Integer))
|
||||
TmpDT.Columns.Add("SubProyecto", GetType(String))
|
||||
TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer))
|
||||
'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto
|
||||
TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer))
|
||||
'Contratos
|
||||
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
||||
'Remisiones a Facturas
|
||||
TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer))
|
||||
'Pedido2 a Facturas
|
||||
TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer))
|
||||
TmpDT.Columns.Add("Origen", GetType(Integer))
|
||||
'Ordenes Servicio
|
||||
TmpDT.Columns.Add("CveOS", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveOSDetalle", GetType(Integer))
|
||||
TmpDT.Columns.Add("SeFacturara", GetType(Integer))
|
||||
TmpDT.Columns.Add("Folio", GetType(Integer))
|
||||
TmpDT.Columns.Add("Estatus", GetType(String))
|
||||
'Ordenamiento
|
||||
TmpDT.Columns.Add("Orden", GetType(Integer))
|
||||
TmpDT.Columns.Add("TipoDocto", GetType(String))
|
||||
'OC
|
||||
TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer))
|
||||
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
|
||||
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
|
||||
TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal))
|
||||
TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal))
|
||||
TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal))
|
||||
TmpDT.Columns.Add("CantidadInventario", GetType(Decimal))
|
||||
TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String))
|
||||
TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String))
|
||||
TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String))
|
||||
TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String))
|
||||
TmpDT.Columns.Add("CveTamaño", GetType(Integer))
|
||||
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
|
||||
|
||||
Return TmpDT
|
||||
End Function
|
||||
Private Function InicializaDTVentasNC() As DataTable
|
||||
Dim DtVentasNC = New DataTable
|
||||
DtVentasNC.Columns.Add("CveVenta", GetType(Integer))
|
||||
DtVentasNC.Columns.Add("Importe", GetType(Decimal))
|
||||
DtVentasNC.Columns.Add("FolioFiscal", GetType(String))
|
||||
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1})
|
||||
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1})
|
||||
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1})
|
||||
|
||||
Return DtVentasNC
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
Private Sub LimpiaCampos()
|
||||
TxtFolio.Text = ""
|
||||
TxtObservaciones.Text = ""
|
||||
|
||||
Reference in New Issue
Block a user