This commit is contained in:
rakcsle
2020-12-28 17:09:18 -07:00
3 changed files with 650 additions and 24 deletions

View File

@@ -1912,6 +1912,27 @@ Namespace Modelos
DtVentasNC.Rows.Add(Dr)
End If
End Sub
Private Function CancelarMovimientosUsados(factura As Modelos.Factura, UsuarioActual As Usuario, ByRef ObjAcum As ClsAcumuladores) As Boolean
Dim Retorno As Boolean = True
If ObjAcum.DistribuidorMovtosGet(factura.CveCliente, UsuarioActual.CveEmpresa, CveVentaRNCCargo:=factura.CveVenta, CveConcepto:=2) Then
Dim CveConceptoSalida As Integer = 2
Dim DtSalidas As DataTable = ObjAcum.DtResultados.FiltraParametros("Cantidad > 0")
If DtSalidas IsNot Nothing AndAlso DtSalidas.Rows.Count > 0 Then
For Each RowSalida As DataRow In DtSalidas.Rows
Dim Cantidad As Decimal = RowSalida("Cantidad").ToString().ToDecimal() * -1
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, Cantidad, RowSalida("CveTamaño").ToString.ToEntero, CveConceptoSalida, factura.CveVenta, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 0D, "") Then
Retorno = False
Exit For
End If
Next
DtSalidas.Dispose()
End If
End If
Return Retorno
End Function
Private Function GuardarUsados(ByRef ObjAcum As ClsAcumuladores, ByRef ObjVentas As ClsVentas, ByRef ObjInventario As ClsInventarios, factura As Modelos.Factura, ByRef Optional Resp As MMensajeFactura = Nothing) As Boolean
Dim Resultado As Boolean = True
@@ -4574,6 +4595,7 @@ Namespace Modelos
Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
Dim ObjContrato As New ClsContratos(ObjVentas.IniciaTransacSQL())
Dim ObjEventos As New ClsOIEventos(ObjVentas.IniciaTransacSQL())
Dim ObjAcum As New ClsAcumuladores(ObjVentas.IniciaTransacSQL())
Dim ObjAC As ClsContPAQi = Nothing
If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
@@ -4990,6 +5012,16 @@ Namespace Modelos
End If
End If
'CANCELA MOVIMIENTOS DE USADOS
If Not ErrorCancelar Then
If ObjFactura.TipoDocto = "Ing" Then
If Not CancelarMovimientosUsados(ObjFactura, UsuarioActual, ObjAcum) Then
ErrorCancelar = True
MensajeError = "Ocurrió un error al cancelar los movimientos de usados"
End If
End If
End If
End If
'MARCA LA VENTA PARA REALIZAR LA DEVOLUCION POSTERIORMENTE

View File

@@ -932,6 +932,7 @@
<th style="width: 100px;" colspan="3">Comandos</th>
<th></th>
<th runat="server" visible="false" id="nomostrar2"></th>
<th runat="server" visible="false" id="thProntoPago2"></th>
</tr>
<tr class="TextTab" runat="server" id="TrEdit">
<th>
@@ -1040,6 +1041,7 @@
<asp:LinkButton ID="LbVerInventario" ClientIDMode="Static" runat="server" CssClass="btn btn-circle btn-sm purple" Text="<i class='icon-magnifier'></i>"></asp:LinkButton>
</th>--%>
<th runat="server" visible="false" id="nomostrar"></th>
<th runat="server" visible="false" id="thProntoPago"></th>
</tr>
</table>
@@ -1255,6 +1257,8 @@
<asp:DropDownList runat="server" ID="DdlFR" AppendDataBoundItems="true" AutoPostBack="true" DataTextField="FuenteRecaudacionCodigoRubroIngreso" DataValueField="CvePresupuestoIngreso" Style="max-width: 100px;" OnSelectedIndexChanged="DdlFR_SelectedIndexChanged"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<%--22--%>
<asp:BoundField DataField="TieneProntoPago" HeaderText="Pronto Pago" ItemStyle-Width="5%" ItemStyle-HorizontalAlign="Center" ReadOnly="true" Visible="false" />
</Columns>
<RowStyle CssClass="Texto" />
<AlternatingRowStyle CssClass="TextoAlterno" />
@@ -1360,19 +1364,26 @@
<div class="col-md-6">
<table id="TbDescuentosRNC" border="0" rules="none" class="well TextTab" style="float: right;" runat="server" visible="false">
<tr align="right">
<td style="border: 1px none white"><b>Descuentos. RNC.:</b></td>
<td style="border: 1px none white"><b>Descuentos RNC:</b></td>
<td>
<asp:Label ID="LblDescuentosRNC" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00" Width="78px"></asp:Label></td>
<td align="right">&nbsp;<asp:LinkButton ID="LnkDescuentosRNC" runat="server" OnClick="LnkDescuentosRNC_Click" Text="<i class='fa fa-tag fa-lg font-green'></i>" AlternateText="Aplicacion de RNC" Style="cursor: pointer;" />
</td>
</tr>
<tr align="right">
<td style="border: 1px none white"><b>Total NC.:</b></td>
<td style="border: 1px none white"><b>Total NC:</b></td>
<td>
<asp:Label ID="LblTotalNC" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00" Width="78px"></asp:Label></td>
<td align="right">&nbsp;
</td>
</tr>
<tr align="right">
<td style="border: 1px none white"><b>Pronto Pago:</b></td>
<td>
<asp:Label ID="LblProntoPago" ClientIDMode="Static" runat="server" Style="text-align: right;" Text="0.00" Width="78px"></asp:Label></td>
<td align="right">&nbsp;
</td>
</tr>
</table>
</div>
</div>
@@ -1576,6 +1587,7 @@
</div>
</div>
<asp:HiddenField ID="HdnTotalRNC" runat="server" ClientIDMode="Static" Value="0" />
<asp:HiddenField ID="HdnProntoPago" runat="server" ClientIDMode="Static" Value="0" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
@@ -7790,7 +7802,10 @@
var totalDebito = ToDouble($get("TxtImporteDebito").value);
var totalCheque = ToDouble($get("TxtImporteCheque").value);
var totalTransferencia = ToDouble($get("TxtImporteTransferencia").value);
var totalRNC = ToDouble($get("HdnTotalRNC").value);
var totalAmortizado = ToDouble($get("HdnAnticipos").value);
var totalProntoPago = ToDouble($get("HdnProntoPago").value);
var TotalOtrosContado = 0;
@@ -7800,7 +7815,7 @@
}
} catch (e) { }
var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC;
var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC + totalAmortizado + totalProntoPago;
var totalVenta = ToDouble($get('TxtTotal').value);
if (total > totalVenta) {
@@ -7809,7 +7824,7 @@
$get("TxtCambio").value = "0.00";
}
$get("TxtImporteContado").value = total - totalRNC;
$get("TxtImporteContado").value = total - totalRNC - totalAmortizado - totalProntoPago;
}
// ****************************************************************************************************************************************************************************

View File

@@ -3995,6 +3995,8 @@ Partial Class Ventas
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
GvPS.DataSource = ObjVentas.DtResultados
GvPS.DataBind()
@@ -7837,6 +7839,25 @@ Partial Class Ventas
End If
End If
End If
Dim SerieFolioNCProntoPago As String = ""
Dim CveVentaNCProntoPago As Integer = -1
Dim GeneroDescuentoProntoPago As Boolean = False
If ObjFactura.DescuentoProntoPago > 0 Then
Dim RespFacturaProntoPago = GenerarNCProntoPago(ObjVentas.IniciaTransacSQL(), ObjClientes, ObjContPaq, ObjFactura)
If RespFacturaProntoPago.ObjFacturaProntoPago Is Nothing OrElse RespFacturaProntoPago Is Nothing Then
ErrorList.Add("No se pudo generar la nota de crédito de pronto pago")
Else
If RespFacturaProntoPago.Mensaje.CveVenta <= 0 OrElse RespFacturaProntoPago.Mensaje.TieneError Then
ErrorList.Add("No se pudo generar la nota de crédito de pronto pago")
Else
GeneroDescuentoProntoPago = True
CveVentaNCProntoPago = RespFacturaProntoPago.Mensaje.CveVenta
SerieFolioNCProntoPago = RespFacturaProntoPago.Mensaje.SerieFolio
Obj2.Add(RespFacturaProntoPago.ObjFacturaProntoPago)
End If
End If
End If
'MARCA PARA NO SURTIR VENTA DE COTNRATO DE CONSIGNACION DE VENTA | [IPP] : PARCHE
If ErrorList.Count = 0 Then
@@ -7936,7 +7957,7 @@ Partial Class Ventas
'ENVIAR POLIZA VIRTUAL
If ErrorList.Count = 0 Then
If UsuarioActual.Empresa.Funcionalidad(576) = "1" Then
If UsuarioActual.Empresa.Funcionalidad(576) = "1" AndAlso EsProduccion Then
GeneraPolizaVentaWS(ObjFactura)
End If
End If
@@ -8029,7 +8050,7 @@ Partial Class Ventas
SeTimbro = ObjTimbrado.TimbrarFactura(UsuarioActual, ObjFactura)
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
If Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
If Not GeneroDescuentoProntoPago AndAlso Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
Dim ofa As Modelos.Factura = CType(Obj2(0), Modelos.Factura)
'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC
If TieneAnticipo AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
@@ -8041,9 +8062,25 @@ Partial Class Ventas
GeneraPDFFactura(ChkEnviarFactura.Checked)
End If
'NOTA DE CREDITO - REFACTURADA - CASO ESPECIAL, TIMBRADO E IMPRESION
If GeneroDescuentoProntoPago AndAlso Not IsNothing(Obj2) AndAlso Obj2.Count > 0 AndAlso SeTimbro Then
Try
Dim ofa As Modelos.Factura = CType(Obj2(Obj2.Count - 1), Modelos.Factura)
'asigna el foliofiscal del ingreso que se acaba de timbrar, cuando es amortización de anticipo con NC
ofa.Timbre.CFDIRelacionados.UUID.Clear()
ofa.Timbre.CFDIRelacionados.UUID.Add(ObjTimbrado.UUID)
ObjTimbrado.TimbrarFactura(UsuarioActual, ofa)
GeneraPDFFactura(ChkEnviarFactura.Checked)
Catch ex As Exception
OnError("Ocurrió un error al timbrar la nota de credito", ex)
End Try
End If
If SeTimbro AndAlso ObjFactura.TipoDocto.Contiene("Ing") Then
EstatusSMS = EnviarSMSTimbrado(ObjEventos)
End If
If Not SeTimbro Then
Alert(ObjTimbrado.MensajeErrorCFDI, TipoMensaje.MsgError)
End If
@@ -8202,6 +8239,10 @@ Partial Class Ventas
MensajeAlert.AppendFormat("<br/><br/>Su cambio es de <b>${0}</b><br/>", TxtCambio.Text.ToDecimal.FormatoNumero(2))
End If
If CveVentaNCProntoPago > 0 Then
MensajeAlert.AppendFormat(String.Format("<br/>La nota de crédito <b>{0}</b> por descuento pronto pago se generó correctamente.<br/><br/>", SerieFolioNCProntoPago))
End If
'MUESTA ALERT OK
' si es elrol 1165-Ventas,EMp:80, o la empresa 119, recarga ventas, para seguir registrando-.
Dim Liga = If(UsuarioActual.CveRol = 1165 Or UsuarioActual.CveEmpresa = 119, "document.location.href=""/Ventas/Ventas.aspx?CveVenta=-1"";", If(CveEmpresaCRM > 0, $"document.location.href=""/CRM/EmpresaCRM.aspx?CveEmpresaCRM={CveEmpresaCRM}"";", $"document.location.href=""/Ventas/Clientes.aspx?CveCliente={CveCliente}&Opt=2"";"))
@@ -9644,6 +9685,7 @@ Partial Class Ventas
End If
ObjFactura.CveTipoRetencion = DdlTipoRetencion.SelectedValue.ToEntero()
ObjFactura.DescuentoProntoPago = HdnProntoPago.Value.ToDecimal()
ObjFactura.NuevaFactura = Me.NuevaFactura
End Sub
@@ -10084,8 +10126,9 @@ Partial Class Ventas
End If
End If
If tPS.Length > 1000 Then
tPS = tPS.Remove(999, tPS.Length - 1)
If tPS.Length >= 1000 Then
Dim tPSRecortado = tPS.Remove(999, tPS.Length - 999)
tPS = tPSRecortado
End If
'condicionante, especial
@@ -10690,8 +10733,14 @@ Partial Class Ventas
factura.Timbre.Comprobante.Serie = ObjVentas.Serie
factura.Timbre.Comprobante.Folio = ObjVentas.Folio.ToString()
If Not GuardarUsados(ObjVentas.IniciaTransacSQL, factura) Then
ErrorList.Add("Error al guardar usados")
If ObjFactura.TipoDocto = "Ing" Then
If Not GuardarUsados(2, ObjVentas.IniciaTransacSQL, factura) Then
ErrorList.Add("Error al guardar usados")
End If
ElseIf ObjFactura.TipoDocto = "Dev" Then
If Not GuardarUsados(1, ObjVentas.IniciaTransacSQL, factura) Then
ErrorList.Add("Error al guardar usados")
End If
End If
If factura.TipoDocto = "Egs" AndAlso NuevaFactura = 1 Then
@@ -12109,7 +12158,7 @@ Partial Class Ventas
importeMovimiento = 0
Case 103 'Descuento
If ObjFactura.Descuento <> 0 AndAlso Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso DdlTipoAmortizacionAnticipo.SelectedValue = "-1" Then
If ObjFactura.Descuento <> 0 AndAlso Not ObjFactura.TipoDocto.Contiene("Rem", "RNC") AndAlso (DdlTipoAmortizacionAnticipo.SelectedValue = "-1" OrElse UsuarioActual.CveEmpresa = 141) Then
importeMovimiento = ObjFactura.Descuento * Multiplicador * ValorMultiplicador
importeMX = Math.Round(importeMovimiento, 2) * tipoCambio * Multiplicador * ValorMultiplicador
@@ -14319,6 +14368,7 @@ Partial Class Ventas
'cuando es amortización por NOTA DE CREDITO
If DdlTipoAmortizacionAnticipo.SelectedValue = "2" Then
LblAntAplicados.Text = String.Format("Amortización por Nota de Crédito: {0:C}", Amortizacion) : LblAntAplicados.Visible = True
HdnAnticipos.Value = Amortizacion.RoundSQL(2).ToString()
Amortizacion = 0
HdnTipoDescuento.Value = "-1"
HdnDescuento.Value = "0"
@@ -15015,6 +15065,8 @@ Partial Class Ventas
If ObjVentas.GetVentaDetalle(ObjFacturaDevolucion.CveVenta) Then
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
End If
ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFacturaDevolucion, -1, TmpDT, ObjAC, -1, ObjBancos, ObjVentas)
Else
@@ -16221,6 +16273,14 @@ Partial Class Ventas
Descuento += ((Cantidad * PU) - TotalFinal)
End If
'SI TIENE PRONTO PAGO CALCULA EL IMPORTE
If RowPorcentaje("ProntoPago").ToString().ToDecimal() > 0 Then
Dim TotalProntoPago As Decimal = (Cantidad * (PU)) - Descuento
Dim PorcentajeProntoPago = RowPorcentaje("ProntoPago").ToString().ToDecimal() / 100D
ObjDescuento.ImporteProntoPago = (TotalProntoPago * PorcentajeProntoPago).RoundSQL(2)
End If
End If
End If
End If
@@ -16254,6 +16314,7 @@ Partial Class Ventas
Dim Cantidad As Decimal = TxtCantidad.Text.ToDecimal
Dim PU As Decimal = If(CvePSAmortizacion > 0, TxtPrecio.Text.Trim.ToDecimal * -1, TxtPrecio.Text.Trim.ToDecimal)
Dim ObjDescuento As Descuentos = CalcularDescuentos(CvePS, Cantidad, PU)
If ObjDescuento.EsPUModificado Then
PU = ObjDescuento.PU
@@ -16262,7 +16323,8 @@ Partial Class Ventas
AgregarProductoServicio(Cantidad, DdlUnidadMedida.SelectedValue.ToEntero(), DdlUnidadMedida.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero(), DdlClasificacion.SelectedItem.Text,
CvePS, "", TxtObsPS.Text.Trim, PU, ObjDescuento.ImporteDescuento,
DdlProyecto.SelectedValue.ToEntero(), DdlProyecto.SelectedItem.Text, DdlSubProyecto.SelectedValue.ToEntero(), DdlSubProyecto.SelectedItem.Text,
Serie:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:=TxtCuentaPredial.Text.Trim, RegeneraIEPS:=ClienteDesglosaIEPS, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle)
Serie:=If(DIVCod.Visible, TxtCodigoSerie.Text.Trim, ""), TiempoEntrega:=TxtTiempoEntrega.Text, CuentaPredial:=TxtCuentaPredial.Text.Trim, RegeneraIEPS:=ClienteDesglosaIEPS, CvePromocionDetalle:=ObjDescuento.CvePromocionDetalle,
ImporteProntoPago:=ObjDescuento.ImporteProntoPago)
CalculaUsados()
@@ -16396,7 +16458,8 @@ Partial Class Ventas
PU As Decimal, Descuento As Decimal, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, Optional Serie As String = "", Optional TiempoEntrega As String = "",
Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "",
Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False) As Boolean
Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False,
Optional ImporteProntoPago As Decimal = 0) As Boolean
Dim Retorno As Boolean = False
Try
@@ -16425,7 +16488,7 @@ Partial Class Ventas
Dim Row As DataRow = Nothing
Dim TotalCalculableImpuestos As Decimal = 0
Dim TotalCalculableImpuestosIVA As Decimal = 0
PU = PU.RoundAD(6) ' el precio unitario puede llevar hasta 6 decimales permitidos
PU = PU.RoundSQL(6) ' el precio unitario puede llevar hasta 6 decimales permitidos
If Not TmpDT.Columns.Contains("RetIVA") Then
TmpDT.Columns.Add("RetIVA", GetType(Decimal))
@@ -16555,24 +16618,24 @@ Partial Class Ventas
Row("IVA") = Row("PorcentajeIVA")
Row("ImporteIVA") = (Row("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundAD(NumeroDecimales)
Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
Row("ImporteIVA") = (Row("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales)
Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
Row("PorcentajeRetIVA") = ClienteRetIVA
Row("PorcentajeRetISR") = ClienteRetISR
Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
Row("ImporteIEPS") = (DrPS("IEPSPorcentaje").ToString().ToDecimal * TotalCalculableImpuestos).RoundAD(NumeroDecimales)
Row("ImporteIEPS") = (DrPS("IEPSPorcentaje").ToString().ToDecimal * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
Row("IEPS") = Row("ImporteIEPS")
Row("Descuento") = (Descuento).RoundAD(NumeroDecimales)
Row("Descuento") = (Descuento).RoundSQL(NumeroDecimales)
Row("TipoDescuento") = HdnTipoDescuento.Value
Row("CvePromocionDetalle") = CvePromocionDetalle
Row("Total") = (Cantidad * PU)
Row("TotalImporte") = (Cantidad * PU).RoundAD(NumeroDecimales)
Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
'Row("AsientoContableVentas") = DrPS("AsientoContableVentas")
' Row("IdCtaContVentas") = IdCtaContable
@@ -16598,6 +16661,14 @@ Partial Class Ventas
Row("EsOutSourcing") = DrPS("EsOutSourcing")
Row("EsCargo") = EsCargo
If ImporteProntoPago > 0 Then
Row("ImporteProntoPago") = ImporteProntoPago
Row("TieneProntoPago") = "Si"
GvPS.Columns(22).Visible = True
thProntoPago.Visible = True
thProntoPago2.Visible = True
End If
If UsuarioActual.CveEmpresa = 119 Then
If Not RemisionesLista.Count > 0 Then 'SI VIENE DE REMISION NO SE CONSIDERA
@@ -16817,9 +16888,15 @@ Partial Class Ventas
TmpDT.Columns.Add("EsCargo", GetType(Boolean))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
TmpDT.Columns("EsOutSourcing").DefaultValue = False
TmpDT.Columns("EsCargo").DefaultValue = False
TmpDT.Columns("TieneProntoPago").DefaultValue = "No"
TmpDT.Columns("ImporteProntoPago").DefaultValue = 0
End Sub
Private Sub CreaDTmpC()
DTmpC = New DataTable
@@ -17242,6 +17319,8 @@ Partial Class Ventas
Dim Total As Decimal = 0
Dim TotalImpuestosLocales As Decimal = 0
Dim TotalProntoPago As Decimal = TmpDT.SUM("ImporteProntoPago").ToDecimal
If TotalAmortizacion > 0 AndAlso TotalSubTotal = TotalAmortizacion Then ' si se amortizó completa la factura, debe de limpiar los impuestos
If DdlTipoAmortizacionAnticipo.SelectedValue.Contiene("3") Then
For Each dr As DataRow In TmpDT.Rows
@@ -17309,6 +17388,9 @@ Partial Class Ventas
TxtIEPS.Text = TotalIEPS.FormatoNumero
TxtTotal.Text = Total.FormatoNumero
HdnProntoPago.Value = TotalProntoPago.ToString()
LblProntoPago.Text = TotalProntoPago.FormatoNumero(2)
LblAmort.Text = TxtSubTotal.Text
If CveVenta <= 0 OrElse (CveDevolucion > 0 And NuevaFactura = 1) Then
HdnVentaSaldo.Value = Total.ToString()
@@ -25076,6 +25158,8 @@ Partial Class Ventas
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
TmpDT.Columns.Add("CveVentaDetalleRNC", GetType(Integer))
TmpDT.Columns.Add("TieneProntoPago", GetType(String))
TmpDT.Columns.Add("ImporteProntoPago", GetType(Decimal))
End If
If AplicaNCMasiva OrElse AplicaNCUsado Then
@@ -26545,6 +26629,12 @@ Partial Class Ventas
Return Nothing
End Function
Private Function AgregaPSCotizacion() As Boolean
'Dim ObjFactCotizacion As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa)
'Dim TotalCotizacion As Decimal = ObjFactCotizacion.Total 'TmpDT.SUM("TotalImporte").ToDecimal() + TmpDT.SUM("ImporteIVA").ToDecimal() + TmpDT.SUM("ImporteIEPS").ToDecimal() - TmpDT.SUM("ImporteRetIVA").ToDecimal() - TmpDT.SUM("ImporteRetISR").ToDecimal()
'ObjFactCotizacion.Dispose()
If DtCotizacionesPS IsNot Nothing Then
Dim tCantidad As Decimal = 0
For Each Dr As DataRow In DtCotizacionesPS.Select()
@@ -26554,6 +26644,15 @@ Partial Class Ventas
Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(),
CveContratoDetalle:=Dr("CveContratoDetalle").ToString().ToEntero(), CveVentaDetalleCotizacion:=Dr("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True)
Next
'Dim TotalFactura = TmpDT.SUM("TotalImporte").ToDecimal() + TmpDT.SUM("ImporteIVA").ToDecimal() + TmpDT.SUM("ImporteIEPS").ToDecimal() - TmpDT.SUM("ImporteRetIVA").ToDecimal() - TmpDT.SUM("ImporteRetISR").ToDecimal()
'Dim Diferencia As Decimal = TotalCotizacion - TotalFactura
'If Diferencia <> 0 Then
' Dim LastRow As DataRow = TmpDT.Rows(TmpDT.Rows.Count - 1)
' LastRow("ImporteIVA") = LastRow("ImporteIVA").ToString().ToDecimal() - Diferencia
'End If
CalculaTotalesVenta()
Return True
Else
@@ -26566,6 +26665,9 @@ Partial Class Ventas
#Region " COTIZACIONES - FACTURAR "
Private Function PreparaFacturarCotizacion() As Boolean
'LIMPIAMOS
'Dim TotalCotizacion As Decimal = TxtTotal.Text.Replace(",", "").ToDecimal()
TmpDT.Rows.Clear()
TxtSubTotal.Text = "0.00"
TxtSubTotal2.Text = "0.00"
@@ -26594,6 +26696,18 @@ Partial Class Ventas
Return False
End If
'Dim TotalFactura As Decimal = TmpDT.SUM("TotalImporte").ToDecimal() + TmpDT.SUM("ImporteIVA").ToDecimal() + TmpDT.SUM("ImporteIEPS").ToDecimal() - TmpDT.SUM("ImporteRetIVA").ToDecimal() - TmpDT.SUM("ImporteRetISR").ToDecimal()
'Dim Diferencia As Decimal = TotalCotizacion - TotalFactura
'If Diferencia <> 0 Then
' Dim LastRow As DataRow = TmpDT.Rows(TmpDT.Rows.Count - 1)
' LastRow("ImporteIVA") = LastRow("ImporteIVA").ToString().ToDecimal() + Diferencia
' CalculaTotalesVenta()
'End If
If TmpDT.Rows.Count = 0 Then
Alert("No hay conceptos por facturar de esta cotización o ha sido cambiada su información. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
Return False
@@ -27985,17 +28099,17 @@ Partial Class Ventas
End If
End Sub
Private Function GuardarUsados(SqlTransaccion As SqlClient.SqlTransaction, factura As Modelos.Factura) As Boolean
Private Function GuardarUsados(CveConcepto As Integer, SqlTransaccion As SqlClient.SqlTransaction, factura As Modelos.Factura) As Boolean
Dim Resultado As Boolean = True
If ClienteEsDistribuidor AndAlso factura.TipoDocto.Contiene("Ing") Then
If ClienteEsDistribuidor Then
Dim ObjAcum As New ClsAcumuladores(SqlTransaccion)
Dim CvePSPSA As Integer = UsuarioActual.Empresa.Funcionalidad(533).ToEntero
For Each drow As DataRow In factura.DtDetalle.Rows
If drow("CveTamaño").ToString.ToEntero > 0 And (CvePSPSA <> drow("CvePS").ToString.ToEntero) Then
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, 2, factura.CveVenta, UsuarioActual.CveUsuario,
If Not ObjAcum.DistribuidorMovtosAdd(factura.CveCliente, drow("Cantidad").ToString.ToEntero, drow("CveTamaño").ToString.ToEntero, CveConcepto, factura.CveVenta, UsuarioActual.CveUsuario,
UsuarioActual.CveEmpresa, 0D, "") Then
Resultado = False
Exit For
@@ -28774,6 +28888,7 @@ Partial Class Ventas
Public CvePromocionDetalle As Integer = -1
Public PU As Decimal = 0
Public EsPUModificado As Boolean = False
Public ImporteProntoPago As Decimal = 0
End Class
Protected Sub btnupEventoBitacora_Click(sender As Object, e As EventArgs)
@@ -29035,4 +29150,468 @@ Partial Class Ventas
#Region " N O T A - D E - C R E D I T O - P R O N T O - P A G O"
Private Function GenerarNCProntoPago(SqlTransaccion As SqlClient.SqlTransaction, ByRef ObjCliente As ClsClientes, ByRef ObjConta As ClsContPAQi, ObjFactura As Modelos.Factura) As MensajeProntoPago
Dim Retorno As New MensajeProntoPago
Dim Resp As New Modelos.Factura.MMensajeFactura
Dim ObjFacturaProntoPago As Modelos.Factura = Nothing
Try
ObjFacturaProntoPago = New Modelos.Factura(UsuarioActual)
ObjFacturaProntoPago.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.TextoLimpio
ObjFacturaProntoPago.CveUsuario = UsuarioActual.CveUsuario
ObjFacturaProntoPago.UsuarioCreo = UsuarioActual.Usuario
Dim CveSubProyecto As Integer = ObjFactura.CveSubProyecto
Dim CveMoneda As Integer = ObjFactura.CveMoneda
Dim CveCliente As Integer = ObjFactura.CveCliente
Dim Folio As Integer = -1
Dim Serie As String = "-1"
ObjFacturaProntoPago.CveEmpresa = UsuarioActual.CveEmpresa
ObjFacturaProntoPago.TipoCambio = If(CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal())
ObjFacturaProntoPago.ConvertirPesos = False
ObjFacturaProntoPago.CveMoneda = CveMoneda
ObjFacturaProntoPago.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {CveMoneda}")
ObjFacturaProntoPago.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {CveMoneda}")
ObjFacturaProntoPago.Serie = Serie
ObjFacturaProntoPago.Folio = Folio
ObjFacturaProntoPago.Fecha = Now
ObjFacturaProntoPago.CvePrePoliza = -1
ObjFacturaProntoPago.CveMetodoPago = 0
ObjFacturaProntoPago.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR)
ObjFacturaProntoPago.FormaPago = 0
ObjFacturaProntoPago.TipoDocto = "Egs"
ObjFacturaProntoPago.Fecha = Now
ObjFacturaProntoPago.Version = "3.3"
ObjFacturaProntoPago.CveMetodoPago33 = 1
ObjFacturaProntoPago.MetodoPago33 = "Pago en una sola exhibición"
ObjFacturaProntoPago.ClaveMetodoPagoSAT = "PUE"
ObjFacturaProntoPago.CveFormaPago33 = 21
ObjFacturaProntoPago.FormaPago33 = "Aplicación de anticipos"
ObjFacturaProntoPago.FormaPagoSAT33 = "30"
ObjFacturaProntoPago.MetodoPago = ""
ObjFacturaProntoPago.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {ObjFacturaProntoPago.CveMetodoPago33}")
ObjFacturaProntoPago.CveSubProyecto = CveSubProyecto
ObjFacturaProntoPago.SetSubProyecto()
ObjFacturaProntoPago.CveCliente = CveCliente
ObjFacturaProntoPago.SetCliente()
If ObjCliente.GetClientes(ObjFacturaProntoPago.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
ObjFacturaProntoPago.CveUsoCFDI = ObjCliente.CveUsoCFDI
ObjFacturaProntoPago.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
ObjFacturaProntoPago.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
ObjFacturaProntoPago.DtDetalle = CreaDTDetalleNCProntoPago()
CargaImpuestosProntoPago(ObjFacturaProntoPago, ObjFactura, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA.ToDecimal, ObjCliente.RetISR.ToDecimal)
End If
End If
If ObjCliente.GetSucursales(CveCliente) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
ObjFacturaProntoPago.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
Else
ObjFacturaProntoPago.CveClienteSucursal = -1
End If
End If
ObjFacturaProntoPago.CveTipoRelacion = 7
ObjFacturaProntoPago.TipoRelacion = "07"
Dim Fol As New List(Of String)
Fol.Add(ObjFactura.FolioFiscal)
ObjFacturaProntoPago.UUIDRelacionados = Fol
Select Case ObjFacturaProntoPago.TipoDocto
Case "Ing"
ObjFacturaProntoPago.TipoDocumento = "Factura"
Case "REM"
ObjFacturaProntoPago.TipoDocumento = "Remision"
Case "Cot"
ObjFacturaProntoPago.TipoDocumento = "Cotizacion"
Case "Egs"
ObjFacturaProntoPago.TipoDocumento = "Nota de Crédito"
Case "Dev"
ObjFacturaProntoPago.TipoDocumento = "Nota de Devolución"
Case Else
ObjFacturaProntoPago.TipoDocumento = ""
End Select
ObjFacturaProntoPago.FechaPago = Now
ObjFacturaProntoPago.CveCorte = -1
ObjFacturaProntoPago.CveMesa = -1
ObjFacturaProntoPago.NumeroPersonas = 0
ObjFacturaProntoPago.CveContrato = -1
ObjFacturaProntoPago.DescripcionContrato = ""
ObjFacturaProntoPago.CveClienteSucursal = -1
ObjFacturaProntoPago.Entrega = ""
ObjFacturaProntoPago.CveAlmacen = -1
Dim DtVentasNC = InicializaDTVentasNCProntoPago()
Dim TotalImporte As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("TotalImporte")
Dim ImporteIVA As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteIVA")
Dim ImporteRetIVA As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteRetIVA")
Dim ImporteRetISR As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteRetISR")
Dim ImporteIEPS As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("ImporteIEPS")
Dim Descuento As Decimal = ObjFacturaProntoPago.DtDetalle.SUMD("Descuento")
Dim Amortizacion As Decimal = 0
Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
'DETALLES
ObjFacturaProntoPago.SubTotal = TotalImporte
ObjFacturaProntoPago.Descuento = Descuento
ObjFacturaProntoPago.Amortizacion = Amortizacion
ObjFacturaProntoPago.IVA = ImporteIVA
ObjFacturaProntoPago.RetIVA = ImporteRetIVA
ObjFacturaProntoPago.RetISR = ImporteRetISR
ObjFacturaProntoPago.IEPS = ImporteIEPS
ObjFacturaProntoPago.Total = Total
ObjFacturaProntoPago.TotalOtrosConceptos = 0
Dim Drt = DtVentasNC.NewRow
Drt("CveVenta") = ObjFactura.CveVenta
Drt("Importe") = ObjFactura.DescuentoProntoPago
Drt("FolioFiscal") = ObjFactura.FolioFiscal
DtVentasNC.Rows.Add(Drt)
DtVentasNC.AcceptChanges()
ObjFacturaProntoPago.DtVentasNC = DtVentasNC
Resp = ObjFacturaProntoPago.EmitirFactura(False, Transac:=SqlTransaccion, ObjContPaqTransac:=ObjConta)
ObjFacturaProntoPago.Dispose()
Catch ex As Exception
Resp.CveVenta = -1
Resp.TieneError = True
OnError("Ocurrio un error al generar la nota de credito de pronto pago", ex)
End Try
Retorno.ObjFacturaProntoPago = ObjFacturaProntoPago
Retorno.Mensaje = Resp
Return Retorno
End Function
Private Sub AgregaTempDTNCProntoPago(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, Serie 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("Serie") = Serie
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 CargaImpuestosProntoPago(ByRef ObjFacturaDevolucion As Modelos.Factura, ObjFactura As 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
DtImpuestos.Merge(CargaDtImpuestosNC(ObjFactura.CveVenta, ObjFactura.DescuentoProntoPago), True, MissingSchemaAction.Ignore)
DtImpuestos = CargaTotalesImpuestosProntoPago(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 As Integer
Dim ArrayNC As String() = UsuarioActual.Empresa.Funcionalidad(591).Split(",".ToCharArray())
Dim NCBonificacion As Integer = 0
If ArrayNC.Length > 6 Then 'CONCEPTO DE PRONTO PAGO
CveSATNC = ArrayNC(6).ToEntero()
End If
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("")
For Each Dr As DataRow In DtImpuestos.Rows
AgregaTempDTNCProntoPago(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 CargaDtImpuestosNCProntoPago(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 = ""
Dim ImporteTotalConcepto As Decimal = 0
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"))
ImporteTotalConcepto = Porcentaje * (TmpDT.SUMD("TotalImporte", FiltroStr) - TmpDT.SUMD("Descuento", FiltroStr))
Dr("ImportePU") = ImporteTotalConcepto.RoundSQL(6)
Dr("ImporteTotal") = ImporteTotalConcepto.RoundSQL(2)
Dr("ImporteIVA") = (ImporteTotalConcepto * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteRetIVA") = (ImporteTotalConcepto * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteRetISR") = (ImporteTotalConcepto * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteIEPS") = (ImporteTotalConcepto * 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("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 CargaTotalesImpuestosProntoPago(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 CreaDTDetalleNCProntoPago() 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("Serie", 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 InicializaDTVentasNCProntoPago() 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
Public Class MensajeProntoPago
Public Property ObjFacturaProntoPago As Modelos.Factura
Public Property Mensaje As Modelos.Factura.MMensajeFactura
End Class
#End Region
End Class