diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb
index 79a6ab882..a4549c442 100644
--- a/App_Code/ClsVentas.vb
+++ b/App_Code/ClsVentas.vb
@@ -1268,17 +1268,19 @@ Public Class ClsVentas
Return Retorno
End Function
- Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Double, PU As Double, IEPS As Double, PorcentajeIEPS As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean
+ Public Function UpdateVentaDetalleRemision(CveVenta As Integer, CvePS As Integer, Cantidad As Decimal, PU As Decimal, IEPS As Decimal, PorcentajeIEPS As Decimal, IVA As Decimal, PorcentajeIVA As Decimal, Observaciones As String, Optional CveUsuarioModifico As Integer = -1) As Boolean
Dim Retorno As Boolean = False
DataAdapter("PA_VentasDetalleRemisionUpdate")
With SqlAdapter.SelectCommand.Parameters
.Add("@CveVentaDetalle", SqlDbType.Int).Value = CveVenta
.Add("@CvePS", SqlDbType.Int).Value = CvePS
- .Add("@Cantidad", SqlDbType.Float).Value = Cantidad
- .Add("@PU", SqlDbType.Float).Value = PU
- .Add("@IEPS", SqlDbType.Float).Value = IEPS
- .Add("@PorcentajeIEPS", SqlDbType.Float).Value = PorcentajeIEPS
+ .Add("@Cantidad", SqlDbType.Decimal).Value = Cantidad
+ .Add("@PU", SqlDbType.Decimal).Value = PU
+ .Add("@IEPS", SqlDbType.Decimal).Value = IEPS
+ .Add("@PorcentajeIEPS", SqlDbType.Decimal).Value = PorcentajeIEPS
+ .Add("@IVA", SqlDbType.Decimal).Value = IVA
+ .Add("@PorcentajeIVA", SqlDbType.Decimal).Value = PorcentajeIVA
.Add("@Observaciones", SqlDbType.VarChar).Value = Observaciones
.Add("@CveUsuarioModifico", SqlDbType.Int).Value = CveUsuarioModifico
End With
diff --git a/Ventas/Ventas.aspx b/Ventas/Ventas.aspx
index 81aaae32d..4d4ed9df2 100644
--- a/Ventas/Ventas.aspx
+++ b/Ventas/Ventas.aspx
@@ -1427,7 +1427,7 @@
|
- <%-- --%>
+ <%-- --%>
|
@@ -2723,7 +2723,7 @@
-
+
@@ -7097,6 +7097,7 @@
+
@@ -7111,6 +7112,7 @@
+
@@ -7427,6 +7429,66 @@
TxtImporte.value = "";
}
}
+ function CalculaSaldoRNCChkDetalle(TxtCantidad, CantidadPendiente, ImporteTotal, Chk) {
+ //ImportesRNCCargo
+ let Importe = 0;
+ if (Chk.checked) {
+ let SaldoMaximoUtilizable = ToDouble(HdnSaldoMaximoUsados.value)
+ let ImportesAsignados = 0;
+
+ $('.ImportesRNCDetalle').each(function () {
+
+ if (Chk.id != $(this).find("td").eq(0).find(":checkbox").attr('id')) {
+ let seleccionado = $(this).find("td").eq(0).find(":checkbox").is(':checked');
+
+ if (seleccionado) {
+ let cantidad = ToDouble($(this).find("td").eq(1).find(":text").val());
+ let porcentajeIVA = ToDouble($(this).find("td").eq(0).find(":hidden").val());
+ let precio = ToDouble($(this).find("td").eq(5).find(":hidden").val());
+
+ let totalcalculableImpuestos = (cantidad * precio);
+ let iva = ToDouble((totalcalculableImpuestos * porcentajeIVA).toFixed(2));
+
+ ImportesAsignados += totalcalculableImpuestos + iva;
+ }
+ }
+
+ });
+
+ Importe = SaldoMaximoUtilizable - ImportesAsignados;
+
+ if (Importe > 0) {
+
+ } else {
+ if (SaldoMaximoUtilizable > 0) {
+ Importe = 0;
+ Chk.checked = false;
+ } else {
+ Importe = 0;
+ }
+ }
+
+ } else {
+ Importe = 0;
+ }
+
+ Importe = ToDouble(Importe.toFixed(2));
+
+ if (Importe > 0) {
+ let pu = (ImporteTotal / CantidadPendiente);
+
+ if (pu > 0) {
+ TxtCantidad.value = (Importe / pu).toString();
+ }
+
+
+ }else {
+ TxtCantidad.value = "0";
+ }
+
+
+ }
+
function LimitaSaldoRNCChk(TxtImporte, Saldo) {
//var Importe = 0;
@@ -8716,21 +8778,21 @@
if (TotalRem == TotalNC) {
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.border = "2px solid #04B431";
- document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #04B431";
- document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "";
- document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "";
+ document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #04B431";
+ document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "";
+ document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "";
- } else {
- document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.border = "2px solid #ff0000";
- document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #ff0000";
- document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "#ff0000";
- document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "#ff0000";
+ } else {
+ document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.border = "2px solid #ff0000";
+ document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #ff0000";
+ document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "#ff0000";
+ document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "#ff0000";
+ }
}
}
- }
- function CerrarModalRemNC() {
- if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') {
+ function CerrarModalRemNC() {
+ if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') {
AplicarValidarRNC(true);
CompararNC();
}
diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb
index 82cf85254..ee3560509 100644
--- a/Ventas/Ventas.aspx.vb
+++ b/Ventas/Ventas.aspx.vb
@@ -2907,6 +2907,15 @@ Partial Class Ventas
End If
MostrarOpcionesPaqueteria()
+ 'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then
+
+ 'If Not AjustarTotalCotizacionFacturada(ViewState("CveCotizacion").ToString().ToEntero(), TxtTotal.Text.ToDecimal) Then
+ ' BtnEmitirImprimir.Visible = True
+ ' Alert("Ocurrió un error al ajustar el importe", TipoMensaje.MsgError)
+ 'End If
+
+ 'End If
+
'UNA VEZ CARGADA LAS CONDICIONES DE PAGO INICIALMENTE, NO VUELVE A SOBREESCRIBIR EL VALOR
CveFormaPago33Cliente = -1
End Sub
@@ -7006,17 +7015,15 @@ Partial Class Ventas
End If
Else
+ Dim DrPS As DataRow = Nothing
+
+ DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
+
If Not ClienteDesglosaIEPS Then
- Dim DrPS As DataRow = Nothing
-
- 'DrPS = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero(), Estatus:=-1).FiltroPrimero("")
-
- DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
-
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)
TmpDT.Rows(e.RowIndex)("PorcentajeIEPS") = 0
- DrPS = Nothing
+
End If
Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (ObjDescuento.ImporteDescuento))
@@ -7039,7 +7046,11 @@ Partial Class Ventas
End If
End If
-
+ If DrPS("IVA").ToString().Contiene("-1", "") Then
+ TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = PorcentajeIVA
+ Else
+ TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = DrPS("IVA")
+ End If
TmpDT.Rows(e.RowIndex)("CveUM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedValue.ToEntero()
TmpDT.Rows(e.RowIndex)("UM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedItem.Text
@@ -7073,6 +7084,8 @@ Partial Class Ventas
TmpDT.Rows(e.RowIndex)("CveSubProyecto") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").SelectedValue
End If
+ DrPS = Nothing
+
GvPS.EditIndex = -1
GvPS.DataSource = TmpDT
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
@@ -9714,7 +9727,7 @@ Partial Class Ventas
ObjFactura.SetSubProyectoMatriz(Me)
ObjFactura.SetSubProyecto(Me)
ObjFactura.ClienteSucursal = New Modelos.SucursalModel()
- If Not CveEmpresaCRM > 0 Then
+ If CveCliente > 0 Then
If Me.ClienteSucursal IsNot Nothing Then
ObjFactura.ClienteSucursal.RFC = Me.ClienteSucursal.RFC
ObjFactura.ClienteSucursal.Nombre = Me.ClienteSucursal.Nombre
@@ -9815,7 +9828,7 @@ Partial Class Ventas
End If
- If Not CveEmpresaCRM > 0 Then ObjFactura.Timbre = PreParaTimbre(ObjFactura)
+ If CveCliente > 0 Then ObjFactura.Timbre = PreParaTimbre(ObjFactura)
'SI SE ESTA EDITANDO ACTUALIZA LOS IMPORTES DEL DT
If GvImpuestosLocales2.Visible AndAlso GvImpuestosLocales2.Enabled Then
@@ -16151,7 +16164,7 @@ Partial Class Ventas
'End If
End Sub
- Private Sub CargaFormatoSucursal()
+ Private Sub CargaFormatoSucursal(Optional RecalcularIVA As Boolean = True)
Dim dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveSubProyecto = {0}", If(DdlSubProyectoDatos.SelectedValue = "", "-1", DdlSubProyectoDatos.SelectedValue)))
If dr IsNot Nothing Then
ViewState("SucCalle") = dr("Calle")
@@ -16182,7 +16195,7 @@ Partial Class Ventas
If CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
DdlIVA.Visible = True
End If
- If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 AndAlso (Not CveVenta > 0 Or EsCreaApartirDe Or CveDevolucion > 0) Then RecalculaIVA()
+ If RecalcularIVA AndAlso TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 AndAlso (Not CveVenta > 0 Or EsCreaApartirDe Or CveDevolucion > 0) Then RecalculaIVA()
'ViewState("SubProyectoPorcentajeIVA") = dr("IVA")
ViewState("TipoFormato") = dr("TipoFormato")
'ViewState("Serie") = dr("Serie")
@@ -16534,7 +16547,7 @@ Partial Class Ventas
If TipoAplicacion = 2 Then
Descuento = 0
SeAjustoPU = True
- PUModificado = PUPromocion
+ PUModificado = Math.Round(PUPromocion / (1 + If(IncluyeImpuestos, PorcentajeIVA, 0)), 6)
Else
Descuento = Descuento + PU - TotalPromocion
End If
@@ -17050,11 +17063,17 @@ Partial Class Ventas
DrPoliza("CveTipoPS") = DrPSAdicional("CveTipoPS")
DrPoliza("CveTipoInvPS") = DrPSAdicional("Inv_CveMetodoInventario")
DrPoliza("NoIdentificacion") = DrPSAdicional("Codigo")
+
If Modalidad = "U" Then
DrPoliza("Consec") = Index
Else
- DrPoliza("Consec") = TmpDT.Rows.Count + 1
+ Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero()
+ If ConsecutivoActual < 0 Then
+ ConsecutivoActual = 0
+ End If
+ DrPoliza("Consec") = ConsecutivoActual + 1
End If
+
Row("Orden") = TmpDT.Rows.Count + 1
DrPoliza("Cantidad") = If(Dr("Cantidad").ToString().ToDecimal > 0, Dr("Cantidad").ToString().ToDecimal, Cantidad)
PU = 0
@@ -17128,6 +17147,249 @@ Partial Class Ventas
Return Retorno
End Function
+ 'Private Function AgregarProductoServicioCotizacion(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
+ ' PU As Decimal, Descuento As Decimal, PorcentajeIVA As Decimal, ImporteIVA 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,
+ ' Optional ImporteProntoPago As Decimal = 0) As Boolean
+
+ ' Dim Retorno As Boolean = False
+ ' Try
+ ' If Not CvePS > 0 Then
+ ' Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgError)
+ ' Return False
+ ' End If
+
+ ' Dim Row As DataRow = Nothing
+ ' Dim TotalCalculableImpuestos As Decimal = 0
+ ' PU = PU.RoundSQL(6) ' el precio unitario puede llevar hasta 6 decimales permitidos
+ ' Descuento = Descuento.RoundSQL(NumeroDecimales)
+
+ ' If Not TmpDT.Columns.Contains("RetIVA") Then
+ ' TmpDT.Columns.Add("RetIVA", GetType(Decimal))
+ ' End If
+
+ ' Row = TmpDT.NewRow()
+ ' Row("CveProyecto") = CveProyecto
+ ' Row("Proyecto") = Proyecto
+ ' Row("CveSubProyecto") = CveSubProyecto
+ ' Row("SubProyecto") = SubProyecto
+ ' Row("Serie") = Serie
+ ' Row("TiempoEntrega") = TiempoEntrega
+ ' If Modalidad = "U" Then
+ ' Row("Orden") = Index
+ ' Else
+ ' Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero()
+ ' If ConsecutivoActual < 0 Then
+ ' ConsecutivoActual = 0
+ ' End If
+ ' Row("Orden") = ConsecutivoActual + 1
+ ' End If
+
+ ' Row("Cantidad") = Cantidad
+ ' Row("CveUM") = CveUM
+ ' Row("UM") = UM
+ ' Row("CveClasificacion") = CveClasificacion
+ ' Row("Clasificacion") = Clasificacion
+ ' Row("CvePS") = CvePS
+ ' Row("Obs") = Obs
+
+
+ ' Dim DrPS As DataRow = Nothing
+
+ ' DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1
+
+ ' If DrPS Is Nothing Then
+ ' Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
+ ' Return False
+ ' End If
+
+ ' If (DrPS("SATClaveUnidadMedida").ToString() = "" Or DrPS("SATClavePS").ToString() = "") Then
+ ' 'VALIDA CLAVESAT
+ ' If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then 'DOCUMENTOS DONDE NO SE VALIDA
+ ' If DrPS("SATClavePS").ToString() = "" Then
+ ' MensajeCveSAT.AppendFormat("{0}-{1}: Sin producto SAT ", DrPS("Codigo").ToString(), DrPS("PS").ToString())
+ ' Return False
+ ' ElseIf DrPS("SATClaveUnidadMedida").ToString() = "" Then
+ ' MensajeCveSAT.AppendFormat("{0}-{1}: Sin Unidad Medida SAT ", DrPS("Codigo").ToString(), DrPS("PS").ToString())
+ ' Return False
+ ' End If
+
+ ' 'If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) AndAlso DrPS("SATClavePS").ToString() = "01010101" Then
+ ' ' MensajeCveSAT.AppendFormat("{0}-{1}: El producto/servicio no existe en el catálogo del SAT ", DrPS("Codigo").ToString(), DrPS("PS").ToString())
+ ' ' Return False
+ ' 'End If
+ ' End If
+ ' Else
+ ' If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) AndAlso DrPS("SATClavePS").ToString() = "01010101" Then
+ ' MensajeCveSAT.AppendFormat("{0}-{1}: El producto/servicio no existe en el catálogo del SAT ", DrPS("Codigo").ToString(), DrPS("PS").ToString())
+ ' Return False
+ ' End If
+ ' End If
+
+ ' 'verifica si tiene ventaminima
+ ' If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString().ToDecimal > 0 Then
+ ' 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
+ ' If Cantidad Mod DrPS("VentaMinima").ToString().ToDecimal <> 0 Then
+ ' Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString()))
+ ' Return False
+ ' End If
+ ' End If
+
+ ' 'VERIFICA SI EN LA FACTURA PADRE SE DESGLOSO EL IEPS
+ ' Dim FacturaDesglosoIEPS As Boolean = ((CveDevolucion > 0 AndAlso NuevaFactura = 1) AndAlso (Me.ObjFacturaNC IsNot Nothing AndAlso Not Me.ObjFacturaNC.VentaDesglosaIEPS))
+
+ ' If Not ClienteDesglosaIEPS Then
+ ' If Not RegeneraIEPS AndAlso Not FacturaDesglosoIEPS Then
+ ' PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)
+ ' VentaDesglosaIEPS = True
+ ' End If
+ ' DrPS("IEPSPorcentaje") = 0
+ ' End If
+ ' 'SI YA SE DESGLOSO EL IEPS SE GUARDA LA BANDERA EN ESTA FACTURA
+ ' If FacturaDesglosoIEPS Then
+ ' VentaDesglosaIEPS = True
+ ' End If
+
+
+ ' TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
+
+ ' Row("PU") = PU
+ ' Row("Codigo") = DrPS("Codigo")
+ ' Row("NoIdentificacion") = DrPS("Codigo")
+ ' Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
+ ' Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
+ ' Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
+ ' Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
+ ' If Modalidad = "U" Then
+ ' Row("Consec") = Index
+ ' Else
+ ' Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero()
+ ' If ConsecutivoActual < 0 Then
+ ' ConsecutivoActual = 0
+ ' End If
+ ' Row("Consec") = ConsecutivoActual + 1
+ ' End If
+
+ ' Row("PS") = DrPS("PS")
+ ' Row("CodigoPS") = DrPS("PSCodigo").ToString()
+ ' Row("CveTipoPS") = DrPS("CveTipoPS")
+ ' Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
+ ' Row("CveTamaño") = DrPS("CveTamaño")
+
+ ' If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion")
+ ' If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion")
+
+ ' Row("PorcentajeIVA") = PorcentajeIVA
+
+ ' Dim ClienteRetIVA = Me.ClienteRetIVA
+
+ ' If ClienteRetIVA <= 0 Then
+ ' If CBool(DrPS("EsOutSourcing").ToString()) Then
+ ' ClienteRetIVA = 0.06D
+ ' DdlTipoRetencion.SelectedValueExist("4")
+ ' ElseIf DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then
+ ' ClienteRetIVA = 0.106667D
+ ' ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then
+ ' ClienteRetIVA = 0.04D
+ ' End If
+ ' End If
+
+ ' LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero
+ ' TrRetIVA.Style.Add("display", "")
+ ' DdlTipoRetencion.Visible = True
+
+
+ ' Row("IVA") = PorcentajeIVA
+ ' Row("ImporteIVA") = (ImporteIVA).RoundSQL(NumeroDecimales)
+ ' Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
+
+
+
+ ' Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
+
+ ' Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
+ ' Row("PorcentajeRetIVA") = ClienteRetIVA
+ ' Row("PorcentajeRetISR") = ClienteRetISR
+ ' Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
+ ' Row("ImporteIEPS") = (DrPS("IEPSPorcentaje").ToString().ToDecimal * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
+ ' Row("IEPS") = Row("ImporteIEPS")
+ ' Row("Descuento") = (Descuento).RoundSQL(NumeroDecimales)
+ ' Row("TipoDescuento") = HdnTipoDescuento.Value
+ ' Row("CvePromocionDetalle") = CvePromocionDetalle
+ ' Row("Total") = (Cantidad * PU)
+ ' Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
+
+ ' 'Row("AsientoContableVentas") = DrPS("AsientoContableVentas")
+ ' ' Row("IdCtaContVentas") = IdCtaContable
+ ' ' Row("AplicaParaConcepto") = AplicaParaConcepto
+
+ ' Row("SATClaveProdServ") = DrPS("SATClavePS")
+ ' Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
+
+ ' If UsuarioActual.Empresa.UsaAC Then
+ ' Row("CvePresupuestoIngreso") = Me.DdlFuenteRecaudacion.SelectedValue
+ ' End If
+
+ ' Row("EntregaDirecta") = EntregaDirecta
+ ' 'Contratos
+ ' Row("CveContratoDetalle") = CveContratoDetalle
+ ' Row("CveVentaDetalle") = CveVentaDetalle
+ ' Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
+ ' Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
+ ' Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
+ ' Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
+ ' Row("CveVentaDetallePedido2") = CveVentaDetallePedido2
+ ' Row("CuentaPredial") = CuentaPredial
+ ' Row("EsOutSourcing") = DrPS("EsOutSourcing")
+ ' Row("EsCargo") = EsCargo
+
+ ' If ImporteProntoPago > 0 Then
+ ' Row("ImporteProntoPago") = ImporteProntoPago
+ ' Row("TieneProntoPago") = "Si"
+ ' 'SOLO DEBE MOSTRASE SI EL PAGO ES DE CONTADO
+ ' If RBLPago.SelectedValue = "2" Then
+ ' GvPS.Columns(22).Visible = True
+ ' thProntoPago.Visible = True
+ ' thProntoPago2.Visible = True
+ ' End If
+
+ ' End If
+
+ ' If UsuarioActual.CveEmpresa = 119 Then
+ ' If Not RemisionesLista.Count > 0 Then 'SI VIENE DE REMISION NO SE CONSIDERA
+
+ ' 'MONEDA DIFERENTE DEL PS AL PRIMER PS AGREGADO
+ ' If DdlMoneda.Enabled = False And CveVenta < 0 And TmpDT.Rows.Count > 0 Then
+ ' If DdlMoneda.SelectedValue <> DrPS("CveMoneda").ToString() Then
+ ' Alert($"La moneda base del producto: {DrPS("PSCodigo").ToString()} es diferente a la moneda del documento.", TipoMensaje.MsgAdvertencia)
+ ' Return False
+ ' End If
+ ' End If
+
+ ' 'ACTIVA PRODUCTOS DE LA MISMA MONEDA
+ ' If TmpDT.Rows.Count = 0 And CveVenta < 0 Then
+ ' DdlMoneda.SelectedValueExist(DrPS("CveMoneda").ToString())
+ ' CambiaMoneda()
+ ' DdlMoneda.Enabled = False
+ ' End If
+ ' End If
+ ' End If
+
+ ' 'RECARGAR GV
+ ' TmpDT.Rows.Add(Row)
+
+ ' Retorno = True
+ ' Catch ex As Exception
+ ' Retorno = False
+ ' OnError("Ocurrió un error al agregar el producto/servicio", ex)
+ ' End Try
+
+
+ ' Return Retorno
+ 'End Function
+
#End Region
#Region "D A T A - T A B L E S"
@@ -17718,6 +17980,9 @@ Partial Class Ventas
If TbDescuentosRNC.Visible AndAlso ListaNCDesc IsNot Nothing Then
TotalRemNCAplicado = ListaNCDesc.Sum(Function(RNC) RNC.TotalRemNCAplicado)
+ If ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0 Then
+ TotalRemNCAplicado += ListaNCBonificacion.Sum(Function(RNC) RNC.TotalRemNCAplicado)
+ End If
End If
Total = (TotalSubTotal - TotalDescuentos - TotalAmortizacion + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales)
@@ -19692,7 +19957,7 @@ Partial Class Ventas
For Each Row As DataRow In TmpDT.Rows
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero()
If CveVentaDetalle > 0 Then
- If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then
+ If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then
OcurrioError = True
Exit For
End If
@@ -19753,6 +20018,12 @@ Partial Class Ventas
End If
End If
+ If Not OcurrioError Then
+ If RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then
+ OcurrioError = True
+ End If
+ End If
+
If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
If ObjConta.ValorPolizaDescuadre > 0 Then
If ObjConta.ValorPolizaDescuadre = 2 Then
@@ -19762,12 +20033,6 @@ Partial Class Ventas
End If
End If
- If Not OcurrioError Then
- If RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then
- OcurrioError = True
- End If
- End If
-
Catch ex As Exception
OcurrioError = True
OnError("Ocurrió un error al actualizar la remisión", ex)
@@ -25054,6 +25319,23 @@ Partial Class Ventas
e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
End If
End Sub
+
+ Protected Sub GvDescNCCargosDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCCargosDetalle.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+
+ If e.Row.DBCampo("CveVentaDetalleRNC").ToEntero() = 0 Then
+ e.Row.CssClass = "Totales"
+ e.Row.FCCheckBox("ChkAplicar").Visible = False
+ e.Row.FCTextBox("TxtCantidadRNC").Visible = False
+ Else
+ e.Row.CssClass = "ImportesRNCDetalle"
+ e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCChkDetalle({e.Row.FCTextBox("TxtCantidadRNC").ClientID},{e.Row.DBCampo("CantidadPendiente").ToDouble},{e.Row.DBCampo("Total").ToDouble}, this);")
+ 'e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
+
+ End If
+ End If
+ End Sub
+
Protected Sub GvDescNCBonificaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCBonificaciones.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCBonChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);")
@@ -25083,15 +25365,6 @@ Partial Class Ventas
End If
End If
End Sub
- Protected Sub GvDescNCCargosDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCCargosDetalle.RowDataBound
- If e.Row.RowType = DataControlRowType.DataRow Then
- If e.Row.DBCampo("CveVentaDetalleRNC").ToEntero() = 0 Then
- e.Row.CssClass = "Totales"
- e.Row.FCCheckBox("ChkAplicar").Visible = False
- e.Row.FCTextBox("TxtCantidadRNC").Visible = False
- End If
- End If
- End Sub
Protected Sub GvRemisionesNCBon_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRemisionesNCBon.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -27034,65 +27307,145 @@ Partial Class Ventas
Dim OcurrioError = False
Dim MensajeError = ""
+ Try
+ 'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS
+ If DdlMoneda.SelectedValue.ToEntero() <> 2 AndAlso ChkConvertirDolares.Checked Then
- 'ACTUALIZA VENTA
- If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), LblDescuentos.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), TxtIVA.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), TxtIEPS.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), TxtTotal.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)),
+ For Each Row As DataRow In TmpDT.Rows
+ Row("PU") = Math.Round(Row("PU").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, 6)
+ Row("Total") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
+ Row("TotalImporte") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
+ Row("Descuento") = Math.Round(Row("Descuento").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteIVA") = Math.Round(Row("ImporteIVA").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteRetIVA") = Math.Round(Row("ImporteRetIVA").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Row("ImporteRetISR") = Math.Round(Row("ImporteRetISR").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ Next
+
+ Dim ImpuestosLocales As Double = 0
+ For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
+ If gvr.RowType = DataControlRowType.DataRow Then
+ gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal).FormatoNumero
+ ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
+ End If
+ Next
+
+ TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
+ LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
+ LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
+ TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
+ TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
+ TxtRetISR.Text = TmpDT.SUM("ImporteRetISR").ToDecimal.FormatoNumero
+ TxtIEPS.Text = TmpDT.SUM("ImporteIEPS").ToDecimal.FormatoNumero
+ TxtTotal.Text = (TxtSubTotal.Text.ToDecimal - LblDescuentos.Text.ToDecimal - LblAmortizacion.Text.ToDecimal + TxtIVA.Text.ToDecimal + TxtIEPS.Text.ToDecimal - TxtRetIVA.Text.ToDecimal - TxtRetISR.Text.ToDecimal - ImpuestosLocales).ToDecimal.FormatoNumero
+
+ TipoCambio = TxtTipoCambioDlls.Text.Trim.ToDecimal
+ Moneda = 2
+ End If
+
+
+ 'CONVERTIR REMISION - TIPO MONEDA -PESO A DOLARES
+ If DdlMoneda.SelectedValue.ToEntero() <> 1 AndAlso ChkConvertirDoctoPesos.Checked Then
+ Dim Importe As Decimal
+ Dim TCC As Decimal = TxtTipoCambio.Text.Trim.ToDecimal
+ For Each Row As DataRow In TmpDT.Rows
+ Row("PU") = Math.Round(Row("PU").ToString().ToDecimal * TCC, 6)
+ Row("Total") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
+ Row("TotalImporte") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
+ Row("Descuento") = Math.Round(Row("Descuento").ToString().ToDecimal * TCC, NumeroDecimales)
+ Importe = Row("Total").ToString().ToDecimal - Row("Descuento").ToString().ToDecimal
+ Row("ImporteIEPS") = Math.Round(Importe * Row("PorcentajeIEPS").ToString().ToDecimal, NumeroDecimales)
+ Row("ImporteIVA") = Math.Round(Importe * Row("PorcentajeIVA").ToString().ToDecimal, NumeroDecimales)
+ Row("ImporteRetIVA") = Math.Round(Importe * Row("PorcentajeRetIVA").ToString().ToDecimal, NumeroDecimales)
+ Row("ImporteRetISR") = Math.Round(Importe * Row("PorcentajeRetISR").ToString().ToDecimal, NumeroDecimales)
+ Next
+
+ Dim ImpuestosLocales As Double = 0
+ For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
+ If gvr.RowType = DataControlRowType.DataRow Then
+ gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * TxtTipoCambio.Text.Trim.ToDecimal).FormatoNumero
+ ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * TxtTipoCambio.Text.Trim.ToDecimal, NumeroDecimales)
+ End If
+ Next
+
+ TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
+ LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
+ LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal * TxtTipoCambio.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
+ TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
+ TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
+ TxtRetISR.Text = TmpDT.SUM("ImporteRetISR").ToDecimal.FormatoNumero
+ TxtIEPS.Text = TmpDT.SUM("ImporteIEPS").ToDecimal.FormatoNumero
+ TxtTotal.Text = (TxtSubTotal.Text.ToDecimal - LblDescuentos.Text.ToDecimal - LblAmortizacion.Text.ToDecimal + TxtIVA.Text.ToDecimal + TxtIEPS.Text.ToDecimal - TxtRetIVA.Text.ToDecimal - TxtRetISR.Text.ToDecimal - ImpuestosLocales).ToDecimal.FormatoNumero
+
+
+ TipoCambio = 1
+ Moneda = 1
+ End If
+
+
+ 'ACTUALIZA VENTA
+ If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDouble(), LblDescuentos.Text.ToDouble(), TxtIVA.Text.ToDouble(), TxtIEPS.Text.ToDouble(), TxtTotal.Text.ToDouble(),
Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim,
UsuarioActual.CveEmpresa, CveVenta, 0, 0,
Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1),
PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero(), CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero(),
CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal,
TipoDocto:=DdlTipoComprobante.SelectedValue, Kilometraje:=TxtKilometraje.Text.ToDouble, CveUsoCFDi:=DdlUsoCFDI.SelectedValue.ToEntero()) Then
- MensajeError = "Ocurrió un error al actualizar la información de la cotización"
- OcurrioError = True
- End If
-
- 'ELIMINA DETALLES
- If Not ObjVentas.RemoveVentasDetalle(CveVenta) Then
- MensajeError = "Ocurrió un error al actualizar las partidas de la cotización"
- OcurrioError = True
- End If
-
- 'RE-INSERTA DETALLES
- For Each Row As DataRow In TmpDT.Rows
- If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDouble, Row("CveUM").ToString().ToEntero(),
- Row("PU").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6),
- Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(),
- PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
- PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then
- MensajeError = "Ocurrió un error al guardar las partidas de la cotización"
+ MensajeError = "Ocurrió un error al actualizar la información de la cotización"
OcurrioError = True
- Exit For
End If
- Next
- For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
- If gvr.RowType = DataControlRowType.DataRow Then
- If Not ObjVentas.UpdateVentaImpuestoLocales(CveVenta, gvr.DataKey("CveImpuestoLocal").ToString().ToEntero(), gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble) Then
- MensajeError = "Ocurrió un error al actualizar los impuestos locales"
+ 'ELIMINA DETALLES
+ If Not ObjVentas.RemoveVentasDetalle(CveVenta) Then
+ MensajeError = "Ocurrió un error al actualizar las partidas de la cotización"
+ OcurrioError = True
+ End If
+
+ 'RE-INSERTA DETALLES
+ For Each Row As DataRow In TmpDT.Rows
+ If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDouble, Row("CveUM").ToString().ToEntero(),
+ Row("PU").ToString().ToDouble(), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble() * (1 + Row("PorcentajeIVA").ToString().ToDouble())), 6),
+ Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(),
+ PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
+ PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then
+ MensajeError = "Ocurrió un error al guardar las partidas de la cotización"
OcurrioError = True
+ Exit For
+ End If
+ Next
+
+ For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
+ If gvr.RowType = DataControlRowType.DataRow Then
+ If Not ObjVentas.UpdateVentaImpuestoLocales(CveVenta, gvr.DataKey("CveImpuestoLocal").ToString().ToEntero(), gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble) Then
+ MensajeError = "Ocurrió un error al actualizar los impuestos locales"
+ OcurrioError = True
+ End If
+ End If
+ Next
+
+ 'ORDEN PRODUCCION
+ If UsuarioActual.CveEmpresa.Contiene(126) Then
+ If CveVenta > 0 And DdlOrdenProduccion.SelectedValue.ToEntero() > 0 Then
+ If Not ObjCGame.UpdateOrdenProduccionVenta(DdlOrdenProduccion.SelectedValue.ToEntero(), CveVenta) Then
+ MensajeError = "Ocurrió un error al actualizar la orden de producción"
+ OcurrioError = True
+ End If
End If
End If
- Next
- 'ORDEN PRODUCCION
- If UsuarioActual.CveEmpresa.Contiene(126) Then
- If CveVenta > 0 And DdlOrdenProduccion.SelectedValue.ToEntero() > 0 Then
- If Not ObjCGame.UpdateOrdenProduccionVenta(DdlOrdenProduccion.SelectedValue.ToEntero(), CveVenta) Then
- MensajeError = "Ocurrió un error al actualizar la orden de producción"
- OcurrioError = True
- End If
- End If
- End If
+ 'If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
+ ' If ObjConta.ValorPolizaDescuadre > 0 Then
+ ' If ObjConta.ValorPolizaDescuadre = 2 Then
+ ' OcurrioError = True
+ ' MensajeError = ObjConta.MensajePolizaDescuadre
+ ' End If
+ ' End If
+ 'End If
+ Catch ex As Exception
+ OcurrioError = True
+ OnError("Ocurrió un error al guardar la cotización", ex)
+ End Try
- 'If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
- ' If ObjConta.ValorPolizaDescuadre > 0 Then
- ' If ObjConta.ValorPolizaDescuadre = 2 Then
- ' OcurrioError = True
- ' MensajeError = ObjConta.MensajePolizaDescuadre
- ' End If
- ' End If
- 'End If
If OcurrioError Then
ObjVentas.RollBack()
@@ -27322,6 +27675,61 @@ Partial Class Ventas
UpPS.Update()
UpParametros.Update()
End Sub
+
+ Private Function AjustarTotalCotizacionFacturada(CveCotizacion As Integer, TotalAjustar As Decimal) As Boolean
+ Dim ErrorAjuste As Boolean = False
+
+ Dim ObjCotizacion As New Modelos.Factura(UsuarioActual, CveCotizacion, UsuarioActual.CveEmpresa)
+
+ If ObjCotizacion.CveMoneda = 1 Then
+ Dim TotalNuevoDocumento As Decimal = TotalAjustar
+
+ Dim Diferencia As Decimal = (ObjCotizacion.Total - TotalNuevoDocumento)
+
+ If Diferencia <> 0 Then
+ 'AJUSTAR EN EL IVA
+ For Each RowNuevoDocumento As DataRow In TmpDT.Rows
+ Dim CveVentaDetalleCotizacion As Integer = RowNuevoDocumento("CveVentaDetalleCotizacion").ToString().ToEntero()
+
+ Dim ImporteIVANuevoDocumento As Decimal = RowNuevoDocumento("ImporteIVA").ToString().ToDecimal()
+ Dim ImporteIEPSNuevoDocumento As Decimal = RowNuevoDocumento("ImporteIEPS").ToString().ToDecimal()
+
+ If CveVentaDetalleCotizacion > 0 Then
+ 'AJUSTAR IVA
+ If ImporteIVANuevoDocumento > 0 Then
+ Dim ImporteIVACotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIVA", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal
+
+ If ImporteIVANuevoDocumento <> ImporteIVACotizacion Then
+ RowNuevoDocumento("ImporteIVA") = ImporteIVACotizacion
+ End If
+ End If
+
+ 'AJUSTAR IEPS
+ If ImporteIEPSNuevoDocumento > 0 Then
+ Dim ImporteIEPSCotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIEPS", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal
+
+ If ImporteIEPSNuevoDocumento <> ImporteIEPSCotizacion Then
+ RowNuevoDocumento("ImporteIEPS") = ImporteIEPSCotizacion
+ End If
+ End If
+
+
+ End If
+ Next
+ End If
+
+ CalculaTotalesVenta(RecalculaImpuestosLocales:=False)
+
+ If Math.Abs(ObjCotizacion.Total - TotalAjustar) > 0 OrElse Math.Abs(TxtTotal.Text.ToDecimal - TotalAjustar) > 0 Then
+ ErrorAjuste = True
+ End If
+
+ End If
+ ObjCotizacion.Dispose()
+
+ Return Not ErrorAjuste
+ End Function
+
Private Class MVentaDetalleCotizacion
Public Property CveVentaDetalle As Integer
Public Property Cantidad As Decimal
@@ -27455,6 +27863,11 @@ Partial Class Ventas
tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal
End If
+ 'AgregarProductoServicioCotizacion(tCantidad, Dr("CveUM").ToString().ToEntero(), Dr("UM").ToString(), Dr("CveClasificacion").ToString().ToEntero(), Dr("Clasificacion").ToString(),
+ ' Dr("CvePS").ToString().ToEntero(), Dr("PS").ToString(), Dr("Obs").ToString(), Dr("PU").ToString().ToDecimal, Dr("Descuento").ToString().ToDecimal,
+ ' Dr("PorcentajeIVA").ToString().ToDecimal, Dr("IVA").ToString().ToDecimal,
+ ' 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)
AgregarProductoServicio(tCantidad, Dr("CveUM").ToString().ToEntero(), Dr("UM").ToString(), Dr("CveClasificacion").ToString().ToEntero(), Dr("Clasificacion").ToString(),
Dr("CvePS").ToString().ToEntero(), Dr("PS").ToString(), Dr("Obs").ToString(), Dr("PU").ToString().ToDecimal, Dr("Descuento").ToString().ToDecimal,
Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(),
@@ -28722,6 +29135,11 @@ Partial Class Ventas
Exit Sub
End If
+ 'If Not AjustarTotalCotizacionFacturada(Me.CveVenta) Then
+ ' Alert("Ocurrió un error al ajustar el importe", TipoMensaje.MsgError)
+ ' Exit Sub
+ 'End If
+
End If
'CARGA LO PENDIENTE POR FACTURAR DE REMISION
|