Plazo del cliente, cachar error al actualizar remisiones
This commit is contained in:
@@ -5015,6 +5015,8 @@ Partial Class Ventas
|
|||||||
|
|
||||||
TrVistaPrevia.Visible = True
|
TrVistaPrevia.Visible = True
|
||||||
|
|
||||||
|
TxtFechaPago.Text = If(DdlTipoComprobante.SelectedValue = "Rem", Now.AddDays(PlazoCobranzaRemision), Now.AddDays(PlazoCobranza)).ToShortDateString
|
||||||
|
|
||||||
If Not (ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then
|
If Not (ModalidadEdicion AndAlso DdlTipoComprobante.SelectedValue = "Rem") Then
|
||||||
CargaRestriccionesCreditoCliente(True, Me.CveVenta)
|
CargaRestriccionesCreditoCliente(True, Me.CveVenta)
|
||||||
End If
|
End If
|
||||||
@@ -16362,181 +16364,186 @@ Partial Class Ventas
|
|||||||
Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click
|
Private Sub BtnEditarRemision_Click(sender As Object, e As EventArgs) Handles BtnEditarRemision.Click
|
||||||
Dim OcurrioError As Boolean = False
|
Dim OcurrioError As Boolean = False
|
||||||
Dim ObjVentas As New ClsVentas
|
Dim ObjVentas As New ClsVentas
|
||||||
|
ObjVentas.IniciaTransacSQL()
|
||||||
|
|
||||||
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
||||||
Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
|
Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
|
||||||
Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL())
|
Dim ObjCGame As New ClsCGame(ObjVentas.IniciaTransacSQL())
|
||||||
Dim ObjAC As ClsContPAQi = Nothing
|
Dim ObjAC As ClsContPAQi = Nothing
|
||||||
|
|
||||||
Dim Moneda As Integer = DdlMoneda.SelectedValue.ToEntero
|
Dim Moneda As Integer = DdlMoneda.SelectedValue.ToEntero
|
||||||
Dim TipoCambio As Double = TxtTipoCambio.Text.ToDouble
|
Dim TipoCambio As Double = TxtTipoCambio.Text.ToDouble
|
||||||
EditoRemision = True
|
EditoRemision = True
|
||||||
'Dim SubTotal, Descuento, IVA, RetIVA, RetISR, IEPS, Total As Decimal
|
Try
|
||||||
ObjVentas.IniciaTransacSQL()
|
'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS
|
||||||
|
If DdlMoneda.SelectedValue.ToEntero <> 2 AndAlso ChkConvertirDolares.Checked Then
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS
|
Dim ImpuestosLocales As Double = 0
|
||||||
If DdlMoneda.SelectedValue.ToEntero <> 2 AndAlso ChkConvertirDolares.Checked Then
|
For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
|
||||||
|
If gvr.RowType = DataControlRowType.DataRow Then
|
||||||
For Each Row As DataRow In TmpDT.Rows
|
gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal).FormatoNumero
|
||||||
Row("PU") = Math.Round(Row("PU").ToString.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, 6)
|
ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||||
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
|
|
||||||
|
|
||||||
'Actualizo los parametros de la venta
|
|
||||||
If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtIEPS.Text.ToDecimal, TxtTotal.Text.ToDecimal, 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, TipoDocto:="Rem", CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal,
|
|
||||||
OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=TxtKilometraje.Text.ToDouble) Then
|
|
||||||
OcurrioError = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
'Cargo de nueva cuenta el detalle de Ventas (Conceptos)
|
|
||||||
If Not OcurrioError Then
|
|
||||||
Dim index As Integer = 0
|
|
||||||
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("Obs").ToString, UsuarioActual.CveUsuario) Then
|
|
||||||
OcurrioError = True
|
|
||||||
Exit For
|
|
||||||
End If
|
End If
|
||||||
Else
|
Next
|
||||||
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),
|
TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
|
||||||
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,
|
LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
|
||||||
CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1),
|
LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
|
||||||
ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString) Then
|
TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
|
||||||
OcurrioError = True
|
TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
|
||||||
Exit For
|
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
|
||||||
|
|
||||||
|
'Actualizo los parametros de la venta
|
||||||
|
If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDecimal, LblDescuentos.Text.ToDecimal, TxtIVA.Text.ToDecimal, TxtIEPS.Text.ToDecimal, TxtTotal.Text.ToDecimal, 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, TipoDocto:="Rem", CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal,
|
||||||
|
OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal, Kilometraje:=TxtKilometraje.Text.ToDouble) Then
|
||||||
|
OcurrioError = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
'Cargo de nueva cuenta el detalle de Ventas (Conceptos)
|
||||||
|
If Not OcurrioError Then
|
||||||
|
Dim index As Integer = 0
|
||||||
|
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("Obs").ToString, UsuarioActual.CveUsuario) Then
|
||||||
|
OcurrioError = True
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
TmpDT.Rows(index)("CveVentaDetalle") = ObjVentas.CveVentaDetalle
|
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,
|
||||||
|
CveVentaDetallePadre:=Row("CveVentaDetalle").ToString.ToEntero, CveContratoDetalle:=Row("CveContratoDetalle").ToString.ToEntero, CvePromocionDetalle:=If(DtPromociones IsNot Nothing, DtPromociones.FiltroPrimeroValor("CvePromocionDetalle", $"CvePS={Row("CvePS").ToString}").ToEntero, -1),
|
||||||
|
ImporteRetIVA:=Row("ImporteRetIVA").ToString.ToDouble, ImporteRetISR:=Row("ImporteRetISR").ToString.ToDouble, PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString.ToDouble, PorcentajeRetISR:=Row("PorcentajeRetISR").ToString.ToDouble, CuentaPredial:=Row("CuentaPredial").ToString) Then
|
||||||
|
OcurrioError = True
|
||||||
|
Exit For
|
||||||
|
Else
|
||||||
|
TmpDT.Rows(index)("CveVentaDetalle") = ObjVentas.CveVentaDetalle
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
index = index + 1
|
||||||
index = index + 1
|
Next
|
||||||
Next
|
End If
|
||||||
End If
|
|
||||||
|
|
||||||
'ELIMINA LOS DETALLES
|
'ELIMINA LOS DETALLES
|
||||||
If Not OcurrioError Then
|
If Not OcurrioError Then
|
||||||
Dim DtEliminados As New DataTable
|
Dim DtEliminados As New DataTable
|
||||||
If ObjVentas.GetVentaDetalle(CveVenta) Then
|
If ObjVentas.GetVentaDetalle(CveVenta) Then
|
||||||
DtEliminados = ObjVentas.DtResultados.FiltraParametros("", "", {"CveVentaDetalle"})
|
DtEliminados = ObjVentas.DtResultados.FiltraParametros("", "", {"CveVentaDetalle"})
|
||||||
For Each Dr1 As DataRow In DtEliminados.Rows
|
For Each Dr1 As DataRow In DtEliminados.Rows
|
||||||
If TmpDT.FiltraParametros($"CveVentaDetalle = {Dr1("CveVentaDetalle")}").Rows.Count = 0 Then
|
If TmpDT.FiltraParametros($"CveVentaDetalle = {Dr1("CveVentaDetalle")}").Rows.Count = 0 Then
|
||||||
If Not ObjVentas.RemoveVentasDetalle(CveVenta, Dr1("CveVentaDetalle").ToString.ToEntero) Then
|
If Not ObjVentas.RemoveVentasDetalle(CveVenta, Dr1("CveVentaDetalle").ToString.ToEntero) Then
|
||||||
|
OcurrioError = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
Else
|
||||||
|
OcurrioError = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'OcurrioError = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, 1, ObjBancos, ObjVentas)
|
||||||
|
|
||||||
|
'Actualizo impuestos locales
|
||||||
|
If Not OcurrioError Then
|
||||||
|
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.ToDecimal) Then
|
||||||
OcurrioError = True
|
OcurrioError = True
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
Else
|
|
||||||
OcurrioError = True
|
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
|
|
||||||
'OcurrioError = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, 1, ObjBancos, ObjVentas)
|
'Orden Produccion'
|
||||||
|
If Not OcurrioError Then
|
||||||
'Actualizo impuestos locales
|
If UsuarioActual.CveEmpresa.Contiene(126) Then
|
||||||
If Not OcurrioError Then
|
If CveVenta > 0 And DdlOrdenProduccion.SelectedValue.ToEntero > 0 Then
|
||||||
For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
|
If Not ObjCGame.UpdateOrdenProduccionVenta(DdlOrdenProduccion.SelectedValue.ToEntero(), CveVenta) Then
|
||||||
If gvr.RowType = DataControlRowType.DataRow Then
|
OcurrioError = True
|
||||||
If Not ObjVentas.UpdateVentaImpuestoLocales(CveVenta, gvr.DataKey("CveImpuestoLocal").ToString.ToEntero, gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDecimal) Then
|
End If
|
||||||
OcurrioError = True
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
End If
|
|
||||||
|
|
||||||
'Orden Produccion'
|
|
||||||
If Not OcurrioError Then
|
|
||||||
If UsuarioActual.CveEmpresa.Contiene(126) Then
|
|
||||||
If CveVenta > 0 And DdlOrdenProduccion.SelectedValue.ToEntero > 0 Then
|
|
||||||
If Not ObjCGame.UpdateOrdenProduccionVenta(DdlOrdenProduccion.SelectedValue.ToEntero(), CveVenta) Then
|
|
||||||
OcurrioError = True
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
|
|
||||||
If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
|
If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
|
||||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||||
If ObjConta.ValorPolizaDescuadre = 2 Then
|
If ObjConta.ValorPolizaDescuadre = 2 Then
|
||||||
|
OcurrioError = True
|
||||||
|
Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Not OcurrioError Then
|
||||||
|
If RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then
|
||||||
OcurrioError = True
|
OcurrioError = True
|
||||||
Alert(ObjConta.MensajePolizaDescuadre, TipoMensaje.MsgError)
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
|
|
||||||
If Not OcurrioError Then
|
Catch ex As Exception
|
||||||
If RegeneracionPolizas(ObjVentas, ObjAC) Then
|
OcurrioError = True
|
||||||
OcurrioError = True
|
OnError("Ocurrió un error al actualizar la remisión", ex)
|
||||||
End If
|
End Try
|
||||||
End If
|
|
||||||
|
|
||||||
If OcurrioError Then
|
If OcurrioError Then
|
||||||
ObjVentas.RollBack()
|
ObjVentas.RollBack()
|
||||||
@@ -17446,34 +17453,26 @@ Partial Class Ventas
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Private Function RegeneracionPolizas(ByRef ObjVentas As ClsVentas, ByRef ObjAC As ClsContPAQi) As Boolean
|
Private Function RegeneracionPolizas(ByRef ObjVentas As ClsVentas, ByRef ObjAC As ClsContPAQi, ByRef ObjConta As ClsContabilidad, ObjBancos As ClsBancos) As Boolean
|
||||||
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
|
||||||
Dim ObjBancos As New ClsBancos(ObjVentas.IniciaTransacSQL())
|
|
||||||
|
|
||||||
Dim CvePlantillaPoliza As Integer
|
|
||||||
|
|
||||||
Dim ErrorCancelar As Boolean = False
|
Dim ErrorCancelar As Boolean = False
|
||||||
Dim Mensaje As String = ""
|
Dim Mensaje As String = ""
|
||||||
|
|
||||||
CreaObjetosVenta()
|
CreaObjetosVenta()
|
||||||
|
|
||||||
If UsuarioActual.Empresa.UsaAC Then
|
If UsuarioActual.Empresa.UsaAC Then
|
||||||
ObjAC = New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
|
ObjAC = New ClsContPAQi(UsuarioActual.Empresa) : ObjAC.IniciaTransacSQL()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then
|
'REMOVEMOS LOS CONCEPTOS DE LA PREPOLIZA
|
||||||
CvePlantillaPoliza = 7
|
ErrorCancelar = Not ObjConta.RemovePrePolizasDetalle(CvePrePoliza, -1, CveVenta, 2)
|
||||||
ElseIf ObjFactura.TipoDocto.Contiene("Ing", "Rem", "Ant") Then
|
|
||||||
CvePlantillaPoliza = 4
|
|
||||||
Else
|
|
||||||
CvePlantillaPoliza = 4
|
|
||||||
End If
|
|
||||||
|
|
||||||
'Removemos los conceptos de la prepoliza
|
|
||||||
ObjConta.RemovePrePolizasDetalle(CvePrePoliza, -1, CveVenta, 2)
|
|
||||||
|
|
||||||
ObjFactura.CveVenta = CveVenta
|
ObjFactura.CveVenta = CveVenta
|
||||||
ObjFactura.CvePrePoliza = CvePrePoliza
|
ObjFactura.CvePrePoliza = CvePrePoliza
|
||||||
ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, 1, ObjBancos, ObjVentas)
|
|
||||||
|
'VUELVE A GENERAR LAS PREPOLIZAS
|
||||||
|
If Not ErrorCancelar Then ErrorCancelar = ProcesoPrepolizas(ObjConta, ObjFactura, -1, TmpDT, ObjAC, 1, ObjBancos, ObjVentas)
|
||||||
|
|
||||||
If Not ErrorCancelar Then ErrorCancelar = GuardarVentaImpuestosLocales(ObjVentas, ObjConta, ObjFactura, 1)
|
If Not ErrorCancelar Then ErrorCancelar = GuardarVentaImpuestosLocales(ObjVentas, ObjConta, ObjFactura, 1)
|
||||||
|
|
||||||
Return ErrorCancelar
|
Return ErrorCancelar
|
||||||
|
|||||||
Reference in New Issue
Block a user