Cancelar movimientos de usados

This commit is contained in:
2020-12-28 12:41:41 -07:00
parent 52515527df
commit d72e542415
3 changed files with 89 additions and 18 deletions

View File

@@ -7791,6 +7791,7 @@
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 TotalOtrosContado = 0;
@@ -7800,7 +7801,7 @@
}
} catch (e) { }
var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC;
var total = totalEfectivo + totalCredito + totalDebito + totalCheque + totalTransferencia + TotalOtrosContado + totalRNC + totalAmortizado;
var totalVenta = ToDouble($get('TxtTotal').value);
if (total > totalVenta) {
@@ -7809,7 +7810,7 @@
$get("TxtCambio").value = "0.00";
}
$get("TxtImporteContado").value = total - totalRNC;
$get("TxtImporteContado").value = total - totalRNC - totalAmortizado;
}
// ****************************************************************************************************************************************************************************

View File

@@ -10084,8 +10084,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 +10691,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 +12116,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 +14326,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"
@@ -16425,7 +16433,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 +16563,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
@@ -26545,6 +26553,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 +26568,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 +26589,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 +26620,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 +28023,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