diff --git a/Ventas/PVCobranza.aspx b/Ventas/PVCobranza.aspx index bca1d3fa9..955d39ca5 100644 --- a/Ventas/PVCobranza.aspx +++ b/Ventas/PVCobranza.aspx @@ -328,7 +328,7 @@ + DataKeyNames="CveVenta,TipoDocto,Saldo,AtencionA,CveFormaPago33,SerieFolio,CondicionesPago"> @@ -482,6 +482,7 @@ +
@@ -606,14 +607,17 @@
-
-
-
- - - -
-
+ + + + +
+
+
+ + + +
@@ -633,8 +637,7 @@ - Serie - Folio - + Serie - Folio @@ -656,17 +659,11 @@ -
- - - + - - - - + Pagado Then - Alert("Favor de especificar el saldo total de pagar", TipoMensaje.MsgAdvertencia) - Exit Sub + If VentaContado Then + 'validaciones + Dim Pagado As Decimal = TxtImporteEfectivo.Text.ToDecimal + TxtImporteCredito.Text.ToDecimal + TxtImporteDebito.Text.ToDecimal + TxtImporteCheque.Text.ToDecimal + TxtImporteTransferencia.Text.ToDecimal + TxtNCDev.Text.ToDecimal() + If Pagado = 0 Then + Alert("Favor de especificar importe", TipoMensaje.ToastAdventencia) + Exit Sub + End If + + If LtlSaldo.Text.ToDecimal() > Pagado Then + Alert("Favor de especificar el saldo total de pagar", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + Dim PagadoSinEfectivo As Decimal = Pagado - TxtImporteEfectivo.Text.ToDecimal + 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) + Exit Sub + End If + + If DivDatosCheque.Visible AndAlso TxtImporteCheque.Text.ToDecimal() > 0 Then + If String.IsNullOrEmpty(TxtClaveAutorizacion.Text.Trim()) Then + Alert("La clave de autorización es necesaria", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If String.IsNullOrEmpty(TxtAutorizo.Text.Trim()) Then + Alert("El nombre de la persona que autorizó es necesario", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If End If - Dim PagadoSinEfectivo As Decimal = Pagado - TxtImporteEfectivo.Text.ToDecimal Dim tCveCorte As Integer = CveCorte - - 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) - Exit Sub - End If - - If DivDatosCheque.Visible AndAlso TxtImporteCheque.Text.ToDecimal() > 0 Then - If String.IsNullOrEmpty(TxtClaveAutorizacion.Text.Trim()) Then - Alert("La clave de autorización es necesaria", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If String.IsNullOrEmpty(TxtAutorizo.Text.Trim()) Then - Alert("El nombre de la persona que autorizó es necesario", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - Dim CveVenta As Integer = HdnCveVenta.Value.ToEntero Dim CveVentaRemision As Integer = -1 @@ -531,7 +539,7 @@ Partial Class Ventas_PVCobranza CveVentaRemision = HdnCveVenta.Value.ToEntero - respFactura = GenerarFactura(CveVendedor, VentaActual, ObjVentas2, ObjClientes, ObservacionesAlmacen) + respFactura = GenerarFactura(CveVendedor, VentaActual, ObjVentas2, ObjClientes, ObservacionesAlmacen, VentaContado) If respFactura Is Nothing Then MsgError = "Ocurrió un error al generar la factura" @@ -575,7 +583,7 @@ Partial Class Ventas_PVCobranza End If If MsgError = "" Then - If SaldoPendiente > 0 Then + If SaldoPendiente > 0 AndAlso VentaContado Then If respFactura IsNot Nothing Then CvePrePoliza = respFactura.Factura.CvePrePoliza @@ -762,7 +770,7 @@ Partial Class Ventas_PVCobranza UpL.Update() End Sub - Private Function GenerarFactura(CveVendedor As Integer, ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes, ObservacionesAlmacen As String) As Modelos.Factura.MMensajeFactura + Private Function GenerarFactura(CveVendedor As Integer, ByRef VentaRemision As Venta, ByRef ObjVentas As ClsVentas, ByRef ObjClientes As ClsClientes, ObservacionesAlmacen As String, VentaConta As Boolean) As Modelos.Factura.MMensajeFactura Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing Dim SbAlert As New StringBuilder() @@ -793,34 +801,27 @@ Partial Class Ventas_PVCobranza DtPagos.Columns.Add(New DataColumn("CveFormaPago", GetType(Integer))) DtPagos.Columns.Add(New DataColumn("Importe", GetType(Decimal))) - If TxtImporteCredito.Text.ToDecimal > 0 Then - DtPagos.Rows.Add({4, TxtImporteCredito.Text.ToDecimal}) - End If + If VentaConta Then + If TxtImporteCredito.Text.ToDecimal > 0 Then DtPagos.Rows.Add({4, TxtImporteCredito.Text.ToDecimal}) - If TxtImporteDebito.Text.ToDecimal > 0 Then - DtPagos.Rows.Add({18, TxtImporteDebito.Text.ToDecimal}) - End If + If TxtImporteDebito.Text.ToDecimal > 0 Then DtPagos.Rows.Add({18, TxtImporteDebito.Text.ToDecimal}) - If TxtImporteCheque.Text.ToDecimal > 0 Then - DtPagos.Rows.Add({2, TxtImporteCheque.Text.ToDecimal}) - End If + If TxtImporteCheque.Text.ToDecimal > 0 Then DtPagos.Rows.Add({2, TxtImporteCheque.Text.ToDecimal}) - If TxtImporteTransferencia.Text.ToDecimal > 0 Then - DtPagos.Rows.Add({3, TxtImporteTransferencia.Text.ToDecimal}) - End If + If TxtImporteTransferencia.Text.ToDecimal > 0 Then DtPagos.Rows.Add({3, TxtImporteTransferencia.Text.ToDecimal}) - If TxtImporteEfectivo.Text.ToDecimal > 0 Then - DtPagos.Rows.Add({1, TxtImporteEfectivo.Text.ToDecimal}) - End If + If TxtImporteEfectivo.Text.ToDecimal > 0 Then DtPagos.Rows.Add({1, TxtImporteEfectivo.Text.ToDecimal}) - - Dim PagoMaximo = DtPagos.MAX("Importe") - - Dim CveFormaPago As Integer = DtPagos.FiltroPrimeroValor("CveFormaPago", $"Importe = {PagoMaximo}").ToEntero() - - If CveFormaPago > 0 Then - ObjFactura.CveFormaPago33 = CveFormaPago - ObjFactura.CveMetodoPago33 = 1 + Dim PagoMaximo = DtPagos.MAX("Importe") + Dim CveFormaPago As Integer = DtPagos.FiltroPrimeroValor("CveFormaPago", $"Importe = {PagoMaximo}").ToEntero() + If CveFormaPago > 0 Then + ObjFactura.CveFormaPago33 = CveFormaPago + ObjFactura.CveMetodoPago33 = 1 + End If + Else + 'venta a crédito + ObjFactura.CveFormaPago33 = 20 ' por definir + ObjFactura.CveMetodoPago33 = 3 'PPD End If For Each Dr As DataRow In ObjFactura.DtRemisionesPS.Rows