-- que tome el cvecorte de la compra, si el usuario no lo tiene activado
-- que tome la fecha del pago en base a la venta
This commit is contained in:
@@ -17,8 +17,6 @@ Partial Class Ventas_PVCobranza
|
|||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Private Property DineroCaja As Double
|
Private Property DineroCaja As Double
|
||||||
Get
|
Get
|
||||||
Return If(IsNothing(ViewState("DineroCaja")), 0, ViewState("DineroCaja").ToString().ToDecimal())
|
Return If(IsNothing(ViewState("DineroCaja")), 0, ViewState("DineroCaja").ToString().ToDecimal())
|
||||||
@@ -183,7 +181,7 @@ Partial Class Ventas_PVCobranza
|
|||||||
If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then
|
If ObjPVenta.GetVta_Cortes("-1", "-1", UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, 0) Then
|
||||||
If ObjPVenta.DtResultados.Rows.Count > 0 Then
|
If ObjPVenta.DtResultados.Rows.Count > 0 Then
|
||||||
|
|
||||||
Total = ObjPVenta.DtResultados(0)("ImporteInicial").ToString().ToDouble + ObjPVenta.DtResultados(0)("VentasEfectivo").ToString().ToDouble + ObjPVenta.DtResultados(0)("Ingresado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Retirado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Devoluciones").ToString().ToDouble
|
Total = ObjPVenta.DtResultados(0)("ImporteInicial").ToString.ToDouble + ObjPVenta.DtResultados(0)("VentasEfectivo").ToString().ToDouble + ObjPVenta.DtResultados(0)("Ingresado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Retirado").ToString().ToDouble - ObjPVenta.DtResultados(0)("Devoluciones").ToString().ToDouble
|
||||||
DineroCaja = Total
|
DineroCaja = Total
|
||||||
LblEfectivoEsperado.Text = Total.FormatoNumero(2)
|
LblEfectivoEsperado.Text = Total.FormatoNumero(2)
|
||||||
LblEfectivoBloqueo.Text = Total.FormatoNumero(2)
|
LblEfectivoBloqueo.Text = Total.FormatoNumero(2)
|
||||||
@@ -388,6 +386,7 @@ Partial Class Ventas_PVCobranza
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Dim PagadoSinEfectivo As Decimal = Pagado - TxtImporteEfectivo.Text.ToDecimal
|
Dim PagadoSinEfectivo As Decimal = Pagado - TxtImporteEfectivo.Text.ToDecimal
|
||||||
|
Dim tCveCorte As Integer = CveCorte
|
||||||
|
|
||||||
If PagadoSinEfectivo > LtlSaldo.Text.ToDecimal() Then
|
If PagadoSinEfectivo > LtlSaldo.Text.ToDecimal() Then
|
||||||
Alert("El pago con los metodos de pago actuales no puede ser mayor al importe de la venta", TipoMensaje.MsgAdvertencia)
|
Alert("El pago con los metodos de pago actuales no puede ser mayor al importe de la venta", TipoMensaje.MsgAdvertencia)
|
||||||
@@ -422,9 +421,10 @@ Partial Class Ventas_PVCobranza
|
|||||||
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
|
VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal
|
||||||
VentaActual.UsuarioActual = UsuarioActual
|
VentaActual.UsuarioActual = UsuarioActual
|
||||||
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
|
VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero
|
||||||
|
If tCveCorte <= 0 AndAlso DbRowVenta("CveCorte").ToString.ToEntero > 0 Then tCveCorte = DbRowVenta("CveCorte").ToString.ToEntero
|
||||||
|
|
||||||
Dim CvePrePoliza As Integer
|
Dim CvePrePoliza As Integer
|
||||||
Dim Fecha As Date = NowADS()
|
Dim Fecha As Date = DbRowVenta("Fecha").ToString.ToDate 'NowADS()
|
||||||
|
|
||||||
Dim MsgError As String = ""
|
Dim MsgError As String = ""
|
||||||
Dim SaldoPendiente As Decimal = DbRowVenta("Saldo").ToString.ToDecimal
|
Dim SaldoPendiente As Decimal = DbRowVenta("Saldo").ToString.ToDecimal
|
||||||
@@ -440,75 +440,76 @@ Partial Class Ventas_PVCobranza
|
|||||||
|
|
||||||
Try
|
Try
|
||||||
'FACTURAR LA REMISION PARA HACER EL PAGO
|
'FACTURAR LA REMISION PARA HACER EL PAGO
|
||||||
If UsuarioActual.CveEmpresa = 189 AndAlso VentaActual.TipoDocto = "Rem" Then
|
If UsuarioActual.CveEmpresa.Contiene(189, 197) AndAlso VentaActual.TipoDocto = "Rem" Then
|
||||||
respFactura = GenerarFactura(VentaActual, ObjVentas2, ObjClientes)
|
respFactura = GenerarFactura(VentaActual, ObjVentas2, ObjClientes)
|
||||||
|
|
||||||
If respFactura Is Nothing Then
|
If respFactura Is Nothing Then
|
||||||
MsgError = "Ocurrío un error al generar la factura"
|
MsgError = "Ocurrió un error al generar la factura"
|
||||||
ElseIf (respFactura IsNot Nothing AndAlso respFactura.Mensajes.Count > 0) AndAlso respFactura.TieneError Then
|
ElseIf (respFactura IsNot Nothing AndAlso respFactura.Mensajes.Count > 0) AndAlso respFactura.TieneError Then
|
||||||
MsgError = respFactura.Mensajes(0)
|
MsgError = respFactura.Mensajes(0)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'REALIZAR EL PAGO EN LA FACTURA
|
'REALIZAR EL PAGO EN LA FACTURA
|
||||||
If respFactura IsNot Nothing AndAlso Not respFactura.TieneError Then
|
If respFactura IsNot Nothing AndAlso Not respFactura.TieneError Then
|
||||||
CveVenta = respFactura.CveVenta
|
CveVenta = respFactura.CveVenta
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
If MsgError = "" Then
|
||||||
|
CvePrePoliza = ObjConta.AddPrePolizas("PVCobranza", 11, 0, 0, 1, Fecha, $"Pago {VentaActual.SerieFolio}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
|
||||||
|
|
||||||
If CvePrePoliza > 0 Then
|
If CvePrePoliza > 0 Then
|
||||||
|
|
||||||
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteCredito.Text.ToDecimal > 0 Then
|
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteCredito.Text.ToDecimal > 0 Then
|
||||||
MsgError = RegistraIE(12, DdlCuentaTarjetaCredito.SelectedValue.ToEntero, TxtImporteCredito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2)
|
MsgError = RegistraIE(12, DdlCuentaTarjetaCredito.SelectedValue.ToEntero, TxtImporteCredito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2, tCveCorte)
|
||||||
SaldoPendiente -= TxtImporteCredito.Text.ToDecimal
|
SaldoPendiente -= TxtImporteCredito.Text.ToDecimal
|
||||||
PagoAplicado += TxtImporteCredito.Text.ToDecimal
|
PagoAplicado += TxtImporteCredito.Text.ToDecimal
|
||||||
End If
|
|
||||||
|
|
||||||
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteDebito.Text.ToDecimal > 0 Then
|
|
||||||
MsgError = RegistraIE(11, DdlCuentaTarjetaDebito.SelectedValue.ToEntero, TxtImporteDebito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2)
|
|
||||||
SaldoPendiente -= TxtImporteDebito.Text.ToDecimal
|
|
||||||
PagoAplicado += TxtImporteDebito.Text.ToDecimal
|
|
||||||
End If
|
|
||||||
|
|
||||||
If SaldoPendiente > 0 AndAlso TxtImporteCheque.Text.ToDecimal > 0 Then
|
|
||||||
MsgError = RegistraIE(3, DdlCuentaCheque.SelectedValue.ToEntero, TxtImporteCheque.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2)
|
|
||||||
SaldoPendiente -= TxtImporteCheque.Text.ToDecimal
|
|
||||||
PagoAplicado += TxtImporteCheque.Text.ToDecimal
|
|
||||||
End If
|
|
||||||
|
|
||||||
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteTransferencia.Text.ToDecimal > 0 Then
|
|
||||||
MsgError = RegistraIE(8, DdlCuentaTransferencia.SelectedValue.ToEntero, TxtImporteTransferencia.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2)
|
|
||||||
SaldoPendiente -= TxtImporteTransferencia.Text.ToDecimal
|
|
||||||
PagoAplicado += TxtImporteTransferencia.Text.ToDecimal
|
|
||||||
End If
|
|
||||||
|
|
||||||
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteEfectivo.Text.ToDecimal > 0 Then
|
|
||||||
Dim PagoEfectivo As Decimal = TxtImporteEfectivo.Text.ToDecimal
|
|
||||||
|
|
||||||
PagoAplicado += PagoEfectivo
|
|
||||||
If PagoAplicado >= SaldoTotalInicial Then
|
|
||||||
TxtCambio.Text = (PagoAplicado - SaldoTotalInicial).FormatoNumero
|
|
||||||
PagoEfectivo = SaldoPendiente
|
|
||||||
End If
|
End If
|
||||||
MsgError = RegistraIE(13, DdlCuentaEfectivo.SelectedValue.ToEntero, PagoEfectivo, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2)
|
|
||||||
SaldoPendiente -= PagoEfectivo
|
|
||||||
End If
|
|
||||||
|
|
||||||
If SaldoPendiente > 0 Then
|
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteDebito.Text.ToDecimal > 0 Then
|
||||||
MsgError = "Tiene saldo pendiente por aplicar"
|
MsgError = RegistraIE(11, DdlCuentaTarjetaDebito.SelectedValue.ToEntero, TxtImporteDebito.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2, tCveCorte)
|
||||||
End If
|
SaldoPendiente -= TxtImporteDebito.Text.ToDecimal
|
||||||
|
PagoAplicado += TxtImporteDebito.Text.ToDecimal
|
||||||
|
End If
|
||||||
|
|
||||||
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, CveCorte) Then
|
If SaldoPendiente > 0 AndAlso TxtImporteCheque.Text.ToDecimal > 0 Then
|
||||||
MsgError = "Error al aplicar el corte"
|
MsgError = RegistraIE(3, DdlCuentaCheque.SelectedValue.ToEntero, TxtImporteCheque.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2, tCveCorte)
|
||||||
End If
|
SaldoPendiente -= TxtImporteCheque.Text.ToDecimal
|
||||||
|
PagoAplicado += TxtImporteCheque.Text.ToDecimal
|
||||||
|
End If
|
||||||
|
|
||||||
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaTicketImpreso(CveVenta, 0) Then
|
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteTransferencia.Text.ToDecimal > 0 Then
|
||||||
MsgError = "No se pudo desmarcar la impresión"
|
MsgError = RegistraIE(8, DdlCuentaTransferencia.SelectedValue.ToEntero, TxtImporteTransferencia.Text.ToDecimal, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2, tCveCorte)
|
||||||
End If
|
SaldoPendiente -= TxtImporteTransferencia.Text.ToDecimal
|
||||||
|
PagoAplicado += TxtImporteTransferencia.Text.ToDecimal
|
||||||
|
End If
|
||||||
|
|
||||||
Else
|
If MsgError = "" AndAlso SaldoPendiente > 0 AndAlso TxtImporteEfectivo.Text.ToDecimal > 0 Then
|
||||||
MsgError = "Error al registrar prepólizas"
|
Dim PagoEfectivo As Decimal = TxtImporteEfectivo.Text.ToDecimal
|
||||||
|
|
||||||
|
PagoAplicado += PagoEfectivo
|
||||||
|
If PagoAplicado >= SaldoTotalInicial Then
|
||||||
|
TxtCambio.Text = (PagoAplicado - SaldoTotalInicial).FormatoNumero
|
||||||
|
PagoEfectivo = SaldoPendiente
|
||||||
|
End If
|
||||||
|
MsgError = RegistraIE(13, DdlCuentaEfectivo.SelectedValue.ToEntero, PagoEfectivo, Fecha, CvePrePoliza, VentaActual, ObjIE, ObjConta, ObjVentas2, tCveCorte)
|
||||||
|
SaldoPendiente -= PagoEfectivo
|
||||||
|
End If
|
||||||
|
|
||||||
|
If SaldoPendiente > 0 Then
|
||||||
|
MsgError = "Tiene saldo pendiente por aplicar"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaCorte(CveVenta, UsuarioActual.CveEmpresa, tCveCorte) Then
|
||||||
|
MsgError = "Error al aplicar el corte"
|
||||||
|
End If
|
||||||
|
|
||||||
|
If MsgError = "" AndAlso Not ObjVentas2.UpdateVentaTicketImpreso(CveVenta, 0) Then
|
||||||
|
MsgError = "No se pudo desmarcar la impresión"
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
MsgError = "Error al registrar prepólizas"
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
MsgError = "Error al registrar el pago"
|
MsgError = "Error al registrar el pago"
|
||||||
@@ -517,16 +518,14 @@ Partial Class Ventas_PVCobranza
|
|||||||
|
|
||||||
If MsgError = "" Then
|
If MsgError = "" Then
|
||||||
ObjVentas2.Commit()
|
ObjVentas2.Commit()
|
||||||
|
Dim msBuild As New StringBuilder()
|
||||||
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
|
'SI SE GENERO FACTURA DE INGRESO, TIMBRARLA DESPUES DE REALIZAR EL PAGO
|
||||||
If respFactura IsNot Nothing Then
|
If respFactura IsNot Nothing Then
|
||||||
If Not respFactura.Factura.TimbrarFactura() Then
|
If Not respFactura.Factura.TimbrarFactura() Then
|
||||||
Alert("La factura no se pudo timbrar", TipoMensaje.MsgAdvertencia)
|
msBuild.Append("La factura no se pudo timbrar<br/> ")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim msBuild As New StringBuilder()
|
|
||||||
|
|
||||||
If respFactura IsNot Nothing Then
|
If respFactura IsNot Nothing Then
|
||||||
msBuild.Append($"Pago Registrado correctamente.")
|
msBuild.Append($"Pago Registrado correctamente.")
|
||||||
For Each m In respFactura.Mensajes
|
For Each m In respFactura.Mensajes
|
||||||
@@ -632,7 +631,7 @@ Partial Class Ventas_PVCobranza
|
|||||||
|
|
||||||
ObjFactura.GenerarSalidaAlmacen = True
|
ObjFactura.GenerarSalidaAlmacen = True
|
||||||
ObjFactura.DtInventario = ObjFactura.DtDetalle.FiltraParametros("CveTipoPS = 2").Copy()
|
ObjFactura.DtInventario = ObjFactura.DtDetalle.FiltraParametros("CveTipoPS = 2").Copy()
|
||||||
ObjFactura.CveAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 1 AND CveSubProyecto = {VentaRemision.CveSubProyecto}").ToString().ToEntero()
|
ObjFactura.CveAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 1 AND CveSubProyecto = {VentaRemision.CveSubProyecto}", "Orden").ToString().ToEntero()
|
||||||
|
|
||||||
ObjFactura.CalculaTotales()
|
ObjFactura.CalculaTotales()
|
||||||
ObjFactura.PreparaTimbre()
|
ObjFactura.PreparaTimbre()
|
||||||
@@ -706,11 +705,11 @@ Partial Class Ventas_PVCobranza
|
|||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas) As String
|
Private Function RegistraIE(Metodo As Integer, CveBancoCuenta As Integer, ImportePago As Decimal, Fecha As Date, CvePrePoliza As Integer, VentaActual As Venta, ByRef ObjIE As ClsBancos, ByRef ObjConta As ClsContabilidad, ByRef ObjVentas As ClsVentas, tCveCorte As Integer) As String
|
||||||
Dim Retorno As String = ""
|
Dim Retorno As String = ""
|
||||||
Dim CveIEPago As Integer = 0
|
Dim CveIEPago As Integer = 0
|
||||||
Dim ErrorConta As Boolean
|
Dim ErrorConta As Boolean
|
||||||
CveIEPago = ObjIE.AddBancos_IE(CveBancoCuenta, Metodo, Fecha, "-1", VentaActual.ClienteNombre, ImportePago, 1, 1, VentaActual.SerieFolio, "", False, True, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=CveCorte)
|
CveIEPago = ObjIE.AddBancos_IE(CveBancoCuenta, Metodo, Fecha, "-1", VentaActual.ClienteNombre, ImportePago, 1, 1, VentaActual.SerieFolio, "", False, True, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCorte:=tCveCorte)
|
||||||
If CveIEPago > 0 Then
|
If CveIEPago > 0 Then
|
||||||
Dim Pago As New VentaPago
|
Dim Pago As New VentaPago
|
||||||
Pago.ImportePagoVenta = ImportePago
|
Pago.ImportePagoVenta = ImportePago
|
||||||
|
|||||||
Reference in New Issue
Block a user