Generar una NC por cada factura y solo aplica cuando es la totalidad de la venta

This commit is contained in:
2020-02-19 20:05:06 -07:00
parent 37627d7f09
commit d1180691c3
2 changed files with 40 additions and 23 deletions

View File

@@ -648,7 +648,8 @@
$get('LbImporteMN').innerHTML = '$ ' + FormatoNumero(SumaConversion, 2) + ' MXN';
}
}
function FnSeleccionaNC(chk, chkNC)
function FnSeleccionaNC(chk, chkNC,txtImporte)
{
if (chk.checked) {
chkNC.disabled = false;
@@ -659,6 +660,11 @@
chkNC.click();
}
}
txtImporte.disabled = chkNC.checked;
}
function FnEditarImporte(chkNC, txtImporte) {
txtImporte.disabled = chkNC.checked;
}
function FnLimites(chk, txt, limiteInferior, limiteSuperior) {

View File

@@ -616,7 +616,7 @@ Partial Class Ventas_ClientesAbonar
End Select
If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 Then
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4}); FnSeleccionaNC({5},{6});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda, e.Row.FCCheckBox("Chk").ClientID, e.Row.FCCheckBox("ChkGenerarNC").ClientID))
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4}); FnSeleccionaNC({5},{6},{0});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda, e.Row.FCCheckBox("Chk").ClientID, e.Row.FCCheckBox("ChkGenerarNC").ClientID))
Else
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo"), e.Row.FCCheckBox("Chk").ClientID, CveMonedaFiltro, moneda))
End If
@@ -646,8 +646,7 @@ Partial Class Ventas_ClientesAbonar
If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() > 0 Then
e.Row.FCCheckBox("ChkGenerarNC").Visible = True
e.Row.FCCheckBox("ChkGenerarNC").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo").ToDecimal - e.Row.DBCampo("DescuentoProntoPago").ToDecimal, e.Row.FCCheckBox("ChkGenerarNC").ClientID, CveMonedaFiltro, moneda))
e.Row.FCCheckBox("ChkGenerarNC").Attributes.Add("onclick", String.Format("FnSuma(this,{0},{1}); FnCambia({2},this,{1},0,{3},{4}); FnEditarImporte({2}, {0});", e.Row.FCTextBox("TxtAbonar").ClientID, e.Row.DBCampo("Saldo").ToDecimal - e.Row.DBCampo("DescuentoProntoPago").ToDecimal, e.Row.FCCheckBox("ChkGenerarNC").ClientID, CveMonedaFiltro, moneda))
End If
Else
@@ -1540,12 +1539,26 @@ Partial Class Ventas_ClientesAbonar
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
If MsgError = "" Then
If ListaFacturasGenerarNC.Count > 0 Then
Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaFacturasGenerarNC)
If Resp.CveVenta > 0 Then
NCGeneradas.Add(Resp)
Else
MsgError = "No se pudo generar la nota de credito"
For Each Fac As Modelos.Factura In ListaFacturasGenerarNC
Dim ListaNC As New List(Of Modelos.Factura)
ListaNC.Add(Fac)
Dim Resp As Modelos.Factura.MMensajeFactura = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaNC)
If Resp.CveVenta > 0 Then
NCGeneradas.Add(Resp)
Else
MsgError = "No se pudo generar la nota de crédito"
Exit For
End If
Next
If MsgError = "" Then
If NCGeneradas.Count <> ListaFacturasGenerarNC.Count Then
MsgError = "No se generaron las notas de crédito seleccionadas"
End If
End If
End If
End If
End If
@@ -1641,21 +1654,14 @@ Partial Class Ventas_ClientesAbonar
If ObjConta IsNot Nothing Then ObjConta.Commit()
Dim StrMsg As New StringBuilder
StrMsg.Append("Abono Registrado Correctamente.<br/>")
StrMsg.AppendFormat("Folio <b><a href='/Bancos/IE.aspx?CveIE={0}' target='_blank' class='Texto'>{1}</a></b>", CveIE, ObjIE.Folio)
StrMsg.AppendFormat("Abono Registrado Correctamente. Folio <b><a href='/Bancos/IE.aspx?CveIE={0}' target='_blank' class='Texto'>{1}</a></b> <br/>", CveIE, ObjIE.Folio)
If IDPoliza > 0 Then StrMsg.AppendFormat("<br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a>", IDPoliza, FolioPoliza)
If IDPoliza > 0 Then StrMsg.AppendFormat("Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a> <br/>", IDPoliza, FolioPoliza)
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
Dim SbMensaje As New StringBuilder
SbMensaje.Append(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
For Each NC In NCGeneradas
For Each msg In NC.Mensajes
StrMsg.Append(msg)
Next
StrMsg.Append("</br>")
StrMsg.AppendFormat("Nota de crédito generada correctamente.<br/><br/> Folio: <a href='/Ventas/Ventas.aspx?CveVenta={0}' target='_blank' class='Texto'>{1}</a><br/>", NC.CveVenta, NC.SerieFolio)
Next
Alert($"{StrMsg.ToString}<br/><br/>{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
@@ -1680,7 +1686,7 @@ Partial Class Ventas_ClientesAbonar
#Region " N O T A - D E - C R E D I T O"
Private Function GenerarNC(Trasac As SqlClient.SqlTransaction, ObjConta As ClsContPAQi, ListaVentasGenerarNC As List(Of Modelos.Factura)) As Modelos.Factura.MMensajeFactura
Private Function GenerarNC(SqlTransaccion As SqlClient.SqlTransaction, ObjConta As ClsContPAQi, ListaVentasGenerarNC As List(Of Modelos.Factura)) As Modelos.Factura.MMensajeFactura
Dim ObjFacturaDevolucion = New Modelos.Factura(UsuarioActual)
ObjFacturaDevolucion.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML
ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
@@ -1844,8 +1850,8 @@ Partial Class Ventas_ClientesAbonar
DtVentasNC.AcceptChanges()
ObjFacturaDevolucion.DtVentasNC = DtVentasNC
'ObjFacturaDevolucion.GenerarPDFFactura = True
Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Transac:=Trasac, ObjContPaqTransac:=ObjConta)
Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Transac:=SqlTransaccion, ObjContPaqTransac:=ObjConta)
ObjFacturaDevolucion.Dispose()
@@ -2370,7 +2376,12 @@ Partial Class Ventas_ClientesAbonar
#End Region
#Region " COMPLEMENTOS PAGO "
Private Function EmitirComplementoPago(CveIE As Integer, CveVentas As List(Of Integer), Series As List(Of String)) As String
Private Function EmitirComplementoPago(CveIE As Integer, CveVentas As List(Of Integer), Series As List(Of String)) As String
If Not UsuarioActual.Empresa.FacturaProduccion Then
Return ""
End If
If Not ChkComplementoPago.Checked Then
Return ""
End If