-
This commit is contained in:
@@ -5918,44 +5918,60 @@
|
||||
}
|
||||
|
||||
|
||||
function chkAnt(t, txt, importe, TotalSaldoCompra, CveMonedaAnticipo, TCAnticipo, CveMonedaOriginal, TCCompra) {
|
||||
var Total = ToDouble($get('TxtTotal').value);
|
||||
debugger;
|
||||
var txtvalue = ToDouble(txt.value);
|
||||
var ImportePago, ImporteCompra;
|
||||
function chkAnt(t, txt, importe, TotalSaldoCompra, CveMonedaAnticipo, TCAnticipo, CveMonedaOriginal, TCCompra, txtComision) {
|
||||
var Total = ToDouble($get('TxtTotal').value);
|
||||
debugger;
|
||||
var txtvalue = ToDouble(txt.value);
|
||||
var ImportePago, ImporteCompra;
|
||||
|
||||
var TCC = TCCompra / TCAnticipo;
|
||||
var importevalue = ToDouble(importe);
|
||||
var TCC = TCCompra / TCAnticipo;
|
||||
var importevalue = ToDouble(importe);
|
||||
|
||||
if (CveMonedaAnticipo != CveMonedaOriginal) {
|
||||
if (CveMonedaAnticipo == 1 && CveMonedaOriginal == 2) {
|
||||
txtvalue = ToDouble(txtvalue / TCAnticipo);
|
||||
importevalue = ToDouble(importevalue / TCAnticipo);
|
||||
} else if (CveMonedaAnticipo == 2 && CveMonedaOriginal == 1) {
|
||||
txtvalue = ToDouble(txtvalue * TCAnticipo);
|
||||
importevalue = ToDouble(importevalue * TCAnticipo);
|
||||
if (CveMonedaAnticipo != CveMonedaOriginal) {
|
||||
if (CveMonedaAnticipo == 1 && CveMonedaOriginal == 2) {
|
||||
txtvalue = ToDouble(txtvalue / TCAnticipo);
|
||||
importevalue = ToDouble(importevalue / TCAnticipo);
|
||||
} else if (CveMonedaAnticipo == 2 && CveMonedaOriginal == 1) {
|
||||
txtvalue = ToDouble(txtvalue * TCAnticipo);
|
||||
importevalue = ToDouble(importevalue * TCAnticipo);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { TCC = 1; }
|
||||
var DifSaldo = (TotalSaldoCompra - FnSumaValoresAnt()).toFixed(2); // le agrego lo del valor actual para validarlo
|
||||
else { TCC = 1; }
|
||||
var DifSaldo = (TotalSaldoCompra - FnSumaValoresAnt());//.toFixed(2); // le agrego lo del valor actual para validarlo
|
||||
|
||||
|
||||
|
||||
if (t.checked)
|
||||
{
|
||||
if (DifSaldo > importevalue) {
|
||||
txt.value = toFixed(ToDouble(importevalue * TCC), 2);
|
||||
} else {
|
||||
txt.value = toFixed(ToDouble(DifSaldo * TCC), 2);
|
||||
}
|
||||
|
||||
|
||||
if (txtComision !== undefined && txtComision !== null) {
|
||||
let difFinal = (DifSaldo - importevalue) * TCC;
|
||||
if (difFinal > 0 && difFinal < 1) {
|
||||
txtComision.value = toFixed(roundToTwo(difFinal), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
txt.value = "";
|
||||
}
|
||||
|
||||
$("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
|
||||
$("#LblAplicadoCompraAnt").text(FormatoNumero(FnSumaValoresAnt(), 2));
|
||||
$("#LblAplicadoCompraAntComision").text(FormatoNumero(FnSumaValoresAntComisiones(), 2));
|
||||
$("#LblSaldoFactura").text(FormatoNumero(TotalSaldoCompra - FnSumaValoresAnt(), 2));
|
||||
|
||||
|
||||
if (t.checked)
|
||||
{
|
||||
if (DifSaldo > importevalue) {
|
||||
txt.value = toFixed(ToDouble(importevalue*TCC),2);
|
||||
} else {
|
||||
txt.value = toFixed(ToDouble(DifSaldo*TCC),2);
|
||||
}
|
||||
} else {
|
||||
txt.value = "";
|
||||
}
|
||||
|
||||
$("#LblTotalAnticipos").text(FormatoNumero(FnSumaValoresAnt(), 2));
|
||||
$("#LblAplicadoCompraAnt").text(FormatoNumero(FnSumaValoresAnt(), 2));
|
||||
$("#LblAplicadoCompraAntComision").text(FormatoNumero(FnSumaValoresAntComisiones(), 2));
|
||||
$("#LblSaldoFactura").text(FormatoNumero(TotalSaldoCompra - FnSumaValoresAnt(), 2));
|
||||
|
||||
|
||||
function roundToTwo(num) {
|
||||
return Math.round(num * 100) / 100;
|
||||
}
|
||||
|
||||
function FnCambiaAnt(chk, txt, saldo, TotalSaldo, CveMonedaAnticipo, TCAnticipo, CveMonedaOriginal, txtComision) {
|
||||
|
||||
@@ -1875,407 +1875,407 @@ Partial Class Compras_Compras
|
||||
CreaDTConceptos()
|
||||
CargaComprobanteXML(XMLDoc)
|
||||
If NuevaValidacionXML = 1 OrElse (Version = "3.3" OrElse Version = "4.0") Then
|
||||
Dim Xml As String
|
||||
Dim nodo As XmlNode = XMLDoc.DocumentElement
|
||||
Dim Version As String = ValorXML(nodo, "version")
|
||||
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
|
||||
Dim cfdVer As String = ""
|
||||
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
|
||||
Dim Xml As String
|
||||
Dim nodo As XmlNode = XMLDoc.DocumentElement
|
||||
Dim Version As String = ValorXML(nodo, "version")
|
||||
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
|
||||
Dim cfdVer As String = ""
|
||||
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
|
||||
|
||||
If Version = "3.2" Then
|
||||
Prefijo = "cfd"
|
||||
cfdVer = "http://www.sat.gob.mx/cfd/2"
|
||||
ElseIf Version = "3.3" Then
|
||||
cfdVer = "http://www.sat.gob.mx/cfd/3"
|
||||
Else ' se considera que es la version 4.0
|
||||
cfdVer = "http://www.sat.gob.mx/cfd/4"
|
||||
End If
|
||||
|
||||
'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
|
||||
|
||||
namespaces.AddNamespace(Prefijo, cfdVer)
|
||||
namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas")
|
||||
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
|
||||
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
|
||||
namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal")
|
||||
|
||||
Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces)
|
||||
Xml = Replace(nodeconceptos.OuterXml, "<cfdi:", "<")
|
||||
Xml = Xml.Replace("</cfdi:", "</")
|
||||
Xml = Xml.Replace("xmlns:cfdi=""http://www.sat.gob.mx/cfd/3""", "")
|
||||
Xml = Xml.Replace("xmlns:cfdi=""http://www.sat.gob.mx/cfd/4""", "")
|
||||
Xml = Xml.Replace(""", "") 'comillas
|
||||
Xml = System.Web.HttpUtility.HtmlDecode(Xml.ToString)
|
||||
Xml = Xml.Replace(Chr(13), "") 'salto de linea
|
||||
Xml = Xml.Replace(Chr(10), "")
|
||||
Xml = Xml.Replace("<br />", "") 'salto de linea html
|
||||
Xml = Xml.Replace("<br>", "")
|
||||
Xml = Xml.Replace("<", "")
|
||||
Xml = Xml.Replace("&", "") 'adicional, si hay otros
|
||||
|
||||
If ObjeFacturas.GetFacturasComparacionXML(Version, Xml, UsuarioActual.CveEmpresa) Then
|
||||
TmpDT = ObjeFacturas.DtResultados
|
||||
TmpDT.Columns.Add("CveSATPSActualizado")
|
||||
SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL
|
||||
|
||||
If Not TmpDT.Columns.Contains("Amortizacion") Then
|
||||
TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
|
||||
End If
|
||||
|
||||
AddPS2(False)
|
||||
|
||||
'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
|
||||
Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
|
||||
For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
|
||||
ProductosCodigoSATNoPermitidos.AppendFormat("{0}</br>", drr("PS"))
|
||||
Next
|
||||
|
||||
If TmpDT.MAX("RetISRPorcentaje").ToDecimal = 0.0125 Then RetISRResico = True
|
||||
If TmpDT.MAX("RetIVAPorcentaje").ToDecimal = 0.04 Then RetIVAFlete = True
|
||||
|
||||
If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
|
||||
Dim mensajeAdvertencia As String = String.Format("El XML que intenta registrar contiene partidas o artículos con código SAT ‘01010101’ el cual no es aceptado, hable con su proveedor para cancelar y/o refacturar un XML válido.<br/> Partidas o artículos con código ‘01010101’: </br></br>{0}", ProductosCodigoSATNoPermitidos.ToString)
|
||||
Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
|
||||
If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso Not UsuarioActual.CveUsuario.Contiene(1719, 1721) Then BtnGuardar.Enabled = False '' solo se activa para el usuario Sara.JAM
|
||||
BtnGuardar.ToolTip = "No se permite registrar facturas con conceptos con código '01010101'. Solicite al proveedor un nuevo comprobante."
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim SbValRet As New StringBuilder
|
||||
For Each concepto As XmlNode In nodeconceptos
|
||||
' Obtener la descripción del concepto
|
||||
Dim descripcion As String = ValorXML(concepto, "Descripcion")
|
||||
Dim importeValue As Decimal = Decimal.Parse(ValorXML(concepto, "Importe"))
|
||||
|
||||
' Seleccionar el nodo de Impuestos dentro de Concepto, si existe
|
||||
Dim impuestosNode As XmlNode = concepto.SelectSingleNode("cfdi:Impuestos", namespaces)
|
||||
|
||||
If Not impuestosNode Is Nothing Then
|
||||
' Seleccionar los nodos de Retencion dentro de Impuestos
|
||||
Dim retenciones As XmlNodeList = impuestosNode.SelectNodes("cfdi:Retenciones/cfdi:Retencion", namespaces)
|
||||
For Each retencion As XmlNode In retenciones
|
||||
' Obtener los valores de los atributos Base e Importe
|
||||
Dim baseValue As Decimal = Decimal.Parse(ValorXML(retencion, "Base"))
|
||||
Dim impuesto As String = ValorXML(retencion, "Impuesto")
|
||||
|
||||
If impuesto = "001" Then
|
||||
impuesto = "Retención ISR"
|
||||
ElseIf impuesto = "002" Then
|
||||
impuesto = "Retención IVA"
|
||||
ElseIf impuesto = "003" Then
|
||||
impuesto = "IEPS"
|
||||
End If
|
||||
|
||||
|
||||
' Validar si Base coincide con Importe
|
||||
If baseValue <> importeValue Then
|
||||
'SbValRet.Append($"La base e importe de la retención del impuesto {impuesto} no coinciden para {descripcion}. Base: {baseValue.ToString()}, Importe: {importeValue.ToString()} <br>")
|
||||
SbValRet.Append($"Producto: {descripcion} La base e importe del impuesto {impuesto} no coincide Base: {baseValue.ToString()}, Importe Producto: {importeValue.ToString()} <br>")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
|
||||
If SbValRet.ToString.Trim.Length > 0 Then
|
||||
Alert(SbValRet.ToString, TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Else
|
||||
CargaConceptosXML(XMLDoc)
|
||||
If Version = "3.2" Then
|
||||
Prefijo = "cfd"
|
||||
cfdVer = "http://www.sat.gob.mx/cfd/2"
|
||||
ElseIf Version = "3.3" Then
|
||||
cfdVer = "http://www.sat.gob.mx/cfd/3"
|
||||
Else ' se considera que es la version 4.0
|
||||
cfdVer = "http://www.sat.gob.mx/cfd/4"
|
||||
End If
|
||||
|
||||
Select Case TipoComprobante
|
||||
Case "ingreso" : DdlTipoComprobante.SelectedValue = "Fac" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV"))
|
||||
Case "egreso" : DdlTipoComprobante.SelectedValue = "NC" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) : ChkAplicaNotaCredito.Enabled = False
|
||||
Case "I"
|
||||
DdlTipoComprobante.SelectedValue = "Fac"
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV"))
|
||||
DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("6"))
|
||||
DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("11"))
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlTipoCompra.Items.Add(New ListItem("Recolección", "14"))
|
||||
Case "E"
|
||||
DdlTipoComprobante.SelectedValue = "NC"
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
|
||||
ChkAplicaNotaCredito.Enabled = False
|
||||
'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2"
|
||||
|
||||
DdlTipoCompra.Items.Clear()
|
||||
DdlTipoCompra.Items.Add(New ListItem("Seleccione", "-1"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("NC Con Productos", "6"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("Garantía", "12"))
|
||||
Case "T"
|
||||
DdlTipoCompra.Items.Clear()
|
||||
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
|
||||
DdlTipoComprobante.SelectedValue = "Fac"
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV"))
|
||||
namespaces.AddNamespace(Prefijo, cfdVer)
|
||||
namespaces.AddNamespace("aerolineas", "http://www.sat.gob.mx/aerolineas")
|
||||
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
|
||||
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
|
||||
namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal")
|
||||
|
||||
End Select
|
||||
Dim nodeconceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces)
|
||||
Xml = Replace(nodeconceptos.OuterXml, "<cfdi:", "<")
|
||||
Xml = Xml.Replace("</cfdi:", "</")
|
||||
Xml = Xml.Replace("xmlns:cfdi=""http://www.sat.gob.mx/cfd/3""", "")
|
||||
Xml = Xml.Replace("xmlns:cfdi=""http://www.sat.gob.mx/cfd/4""", "")
|
||||
Xml = Xml.Replace(""", "") 'comillas
|
||||
Xml = System.Web.HttpUtility.HtmlDecode(Xml.ToString)
|
||||
Xml = Xml.Replace(Chr(13), "") 'salto de linea
|
||||
Xml = Xml.Replace(Chr(10), "")
|
||||
Xml = Xml.Replace("<br />", "") 'salto de linea html
|
||||
Xml = Xml.Replace("<br>", "")
|
||||
Xml = Xml.Replace("<", "")
|
||||
Xml = Xml.Replace("&", "") 'adicional, si hay otros
|
||||
|
||||
'DIV ALIAS
|
||||
CargaPSAlias()
|
||||
|
||||
RFC = dr("RFCDe").ToString
|
||||
RFCProveedor = RFC
|
||||
TxtFecha.Text = dr("FechaFactura").ToString.ToDate.ToShortDateString
|
||||
TxtSerie.Text = dr("Serie").ToString
|
||||
TxtFolio.Text = dr("Folio").ToString
|
||||
DdlValidadaSAT.SelectedValue = If(dr("FueValidado").ToString.Contiene("Si", "1"), "Si", "No")
|
||||
DdlValidadaSAT.Enabled = False
|
||||
LblTipoFact.Text = dr("TipoFactura").ToString
|
||||
SerieVieja = dr("Serie").ToString
|
||||
LblMetodoPago.Text = MetodoPago
|
||||
|
||||
Dim SubTotal2, IVA, IEPS As Decimal
|
||||
IVA = TrasladoIVA
|
||||
|
||||
If Not UsuarioActual.TienePermisoProceso(130) Then
|
||||
TxtFolio.Enabled = False
|
||||
TxtSerie.Enabled = False
|
||||
End If
|
||||
|
||||
'PERMISO PARA MODIFICACIÓN DE FECHA AUN CON FACTURA
|
||||
TxtFecha.Enabled = UsuarioActual.TienePermisoProceso(216)
|
||||
ImgFecha.Enabled = UsuarioActual.TienePermisoProceso(216)
|
||||
CEFecha.Enabled = UsuarioActual.TienePermisoProceso(216)
|
||||
|
||||
TxtSubTotal.Enabled = False
|
||||
TxtDescuento.Enabled = False
|
||||
TxtSubTotal2.Enabled = False
|
||||
TxtIVA.Enabled = False
|
||||
TxtTotal.Enabled = False
|
||||
DdlProveedor.Enabled = False
|
||||
|
||||
If TxtFolio.Text.Trim = "" Then TxtFolio.Enabled = True : TxtSerie.Enabled = True
|
||||
|
||||
If UsuarioActual.TienePermisoProceso(112) Then
|
||||
PermisoEdicionManual = True
|
||||
TxtSubTotal.Enabled = True
|
||||
TxtDescuento.Enabled = True
|
||||
TxtSubTotal2.Enabled = True
|
||||
TxtIVA.Enabled = True
|
||||
TxtTotal.Enabled = True
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(118) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Fac" Then
|
||||
VerVales.Visible = True
|
||||
End If
|
||||
|
||||
If TieneAnticiposXML Then 'si tiene anticipos, limpia los descuentos
|
||||
'LblAmortizacion.Text = ImporteAnticipo.FormatoNumero
|
||||
TxtDescuento.Text = "0.00"
|
||||
LblAmortizacion.Text = Descuentos.FormatoNumero
|
||||
'limpia los descuentos
|
||||
For Each drr As DataRow In TmpDT.Rows
|
||||
'drr("Total") = drr("Total").ToString.ToDecimal + drr("Descuento").ToString.ToDecimal
|
||||
drr("Amortizacion") = drr("Descuento") 'pasamos el importe de descuento a amortizacion
|
||||
drr("Descuento") = 0.00
|
||||
Next
|
||||
Amortizaciones = Descuentos
|
||||
Descuentos = 0
|
||||
End If
|
||||
|
||||
Dim Msg As String = ""
|
||||
If Version = "3.3" Or Version = "4.0" Then
|
||||
If ObjeFacturas.GetFacturasComparacionXML(Version, Xml, UsuarioActual.CveEmpresa) Then
|
||||
TmpDT = ObjeFacturas.DtResultados
|
||||
TmpDT.Columns.Add("CveSATPSActualizado")
|
||||
SubTotalConceptos = TmpDT.SUMD("Total").RoundSQL
|
||||
|
||||
If Not TmpDT.Columns.Contains("Amortizacion") Then
|
||||
TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
|
||||
End If
|
||||
TmpDT.AcceptChanges()
|
||||
ValidacionesTotalesXml()
|
||||
Else
|
||||
'PRUEBA
|
||||
'http://rm/Compras/Compras.aspx?CveFactura=122518 Emp: 48
|
||||
|
||||
'tTotal = Math.Round(SubTotal2 + IVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos, 2)
|
||||
HdnCompraSaldo.Value = Total.ToString
|
||||
CompraSaldo = Total
|
||||
Dim AjustaUltimoConcepto As Boolean = False
|
||||
AddPS2(False)
|
||||
|
||||
'AGREGA IEPS COMO CONCEPTO
|
||||
If TrasladoIEPS > 0 And UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then
|
||||
AgregarConceptoIEPS(TrasladoIEPS, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero)
|
||||
' TrasladoIEPS = 0
|
||||
'VALIDA QUE EL XML SI VIENE CON EL CODIGO SAT 01010101
|
||||
Dim ProductosCodigoSATNoPermitidos As New StringBuilder("")
|
||||
For Each drr As DataRow In TmpDT.FiltraParametros("ClaveProdServ = '01010101'").Rows
|
||||
ProductosCodigoSATNoPermitidos.AppendFormat("{0}</br>", drr("PS"))
|
||||
Next
|
||||
|
||||
If TmpDT.MAX("RetISRPorcentaje").ToDecimal = 0.0125 Then RetISRResico = True
|
||||
If TmpDT.MAX("RetIVAPorcentaje").ToDecimal = 0.04 Then RetIVAFlete = True
|
||||
|
||||
If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then
|
||||
Dim mensajeAdvertencia As String = String.Format("El XML que intenta registrar contiene partidas o artículos con código SAT ‘01010101’ el cual no es aceptado, hable con su proveedor para cancelar y/o refacturar un XML válido.<br/> Partidas o artículos con código ‘01010101’: </br></br>{0}", ProductosCodigoSATNoPermitidos.ToString)
|
||||
Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia)
|
||||
If UsuarioActual.CveEmpresa.Contiene(119, 158) AndAlso Not UsuarioActual.CveUsuario.Contiene(1719, 1721) Then BtnGuardar.Enabled = False '' solo se activa para el usuario Sara.JAM
|
||||
BtnGuardar.ToolTip = "No se permite registrar facturas con conceptos con código '01010101'. Solicite al proveedor un nuevo comprobante."
|
||||
End If
|
||||
'en otro impuesto lo esta registrando en ajuste en automatico
|
||||
If OtrosImpuestos > 0 Then
|
||||
AjustaUltimoConcepto = True
|
||||
End If
|
||||
|
||||
If RFC = "CFE370814QI0" Then ' RFC de CFE, se hace un ajuste por diferencia para sacar el DAP
|
||||
'OtrosImpuestos = Total - (SubTotal2 + IVA)
|
||||
'este importe lo vamos a meter al gasto
|
||||
'AjustaImporteUltimoConcepto(OtrosImpuestos)
|
||||
OtrosImpuestos = 1
|
||||
AjustaUltimoConcepto = True
|
||||
'SubTotal2 = SubTotal
|
||||
End If
|
||||
|
||||
Dim SubTotalReal As Decimal = 0
|
||||
SubTotalReal = Math.Round(Total + RetencionISR + RetencionIVA - IVA + Descuentos - TrasladoIEPS, 2) ' NO se incluye otros impuestos para ajustar esa cifra
|
||||
Dim DiferenciaTotales As Decimal = SubTotalReal - Math.Round(SubTotalConceptos, 2)
|
||||
|
||||
If DiferenciaTotales <> 0 Then
|
||||
'Verificamos IEPS y Otros Impuestos
|
||||
'restricccion general, que si el subtotal de los conceptos no cuadra con Total + RetISR + RetIVA - IVA <> SubTotalConeptos, ajuste al final
|
||||
If TrasladoIEPS > 0 OrElse OtrosImpuestos > 0 OrElse Math.Abs(DiferenciaTotales) < 1 Then
|
||||
|
||||
'Condicion necesaria cuando hay IVA pero no hay diferencia
|
||||
If DiferenciaTotales <> 0 Then
|
||||
|
||||
If DiferenciaTotales < 50 OrElse AjustaUltimoConcepto = True Then
|
||||
Dim IA As Decimal = Total + RetencionISR + RetencionIVA - IVA - SubTotalConceptos - TrasladoIEPS + Descuentos
|
||||
AjustaImporteUltimoConcepto(IA, True)
|
||||
|
||||
ElseIf DiferenciaTotales > 50 Then
|
||||
PnlAjusteProductos.Visible = True
|
||||
Dim Porcentaje As Double = Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2)
|
||||
TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero
|
||||
Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente <br>")
|
||||
ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False
|
||||
|
||||
'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias
|
||||
For Each Row As GridViewRow In GvPS.Rows
|
||||
Row.FCLinkButton("imgE").Visible = False
|
||||
Row.FCLinkButton("imgD").Visible = False
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
TrasladoIEPS = 0 : OtrosImpuestos = 0 : SubTotal2 = SubTotal
|
||||
Else
|
||||
PnlAjusteProductos.Visible = True
|
||||
Dim Porcentaje As Double = If(SubTotalConceptos > 0, Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2), 0)
|
||||
TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero
|
||||
Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente <br>")
|
||||
ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False
|
||||
|
||||
'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias
|
||||
For Each Row As GridViewRow In GvPS.Rows
|
||||
Row.FCLinkButton("imgE").Visible = False
|
||||
Row.FCLinkButton("imgD").Visible = False
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
'Si no hay diferencias pero tenemos descuento, se ofrece la opcion para ajustar el gasto
|
||||
If Descuentos > 0 Then
|
||||
|
||||
'[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018
|
||||
If CveFactura = 286290 Then
|
||||
|
||||
Else
|
||||
PnlAjusteProductos.Visible = True
|
||||
Dim Porcentaje As Double = Math.Round((Descuentos) / (SubTotalConceptos) * 100, 4)
|
||||
TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero(4)
|
||||
Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente <br>")
|
||||
ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False
|
||||
|
||||
'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias
|
||||
For Each Row As GridViewRow In GvPS.Rows
|
||||
Row.FCLinkButton("imgE").Visible = False
|
||||
Row.FCLinkButton("imgD").Visible = False
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
SubTotal2 = SubTotalReal - Descuentos
|
||||
|
||||
If Descuentos > 0 Then
|
||||
TrDescuento.Visible = True
|
||||
End If
|
||||
|
||||
If Msg <> "" Then
|
||||
Alert(Msg, TipoMensaje.MsgAdvertencia)
|
||||
BtnGuardar.Enabled = False
|
||||
End If
|
||||
'AJUSTAMOS SUBTOTAL EN CASO DE SER DIFERENTE AL SUBTOTAL2 DEL XML (TOTAL - IVA)
|
||||
If SubTotal2 <> SubTotal Then
|
||||
SubTotal = SubTotalConceptos
|
||||
End If
|
||||
|
||||
TxtSubTotal.Text = SubTotal.FormatoNumero
|
||||
TxtDescuento.Text = Descuentos.FormatoNumero
|
||||
TxtSubTotal2.Text = SubTotal2.FormatoNumero
|
||||
TxtIVA.Text = IVA.FormatoNumero
|
||||
TxtTotal.Text = Total.ToString.FormatoNumero
|
||||
|
||||
HfTotalCompra.Value = Total.ToString
|
||||
CompraSaldo = Total
|
||||
|
||||
CalculaTotalPorDevengar()
|
||||
TxtDocumentoImporteFE.Text = Total.ToString
|
||||
RVDocumentoImporte.MaximumValue = Math.Round(Total, 2).ToString
|
||||
RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue
|
||||
RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue
|
||||
TxtDocumentoImporte.Text = Total.FormatoNumero
|
||||
TxtDocumentoImporteCaja.Text = Total.FormatoNumero
|
||||
TxtRetIVA.Text = RetencionIVA.FormatoNumero
|
||||
TxtRetISR.Text = RetencionISR.FormatoNumero
|
||||
TxtIEPS.Text = IEPS.FormatoNumero
|
||||
If IEPS > 0 Then TrIEPS.Visible = True
|
||||
If RetencionIVA > 0 Then TrRetIVA.Visible = True
|
||||
If RetencionISR > 0 Then TrRetISR.Visible = True
|
||||
TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero
|
||||
If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True
|
||||
|
||||
HFDiferenciaCompra.Value = TxtTotal.Text
|
||||
'ASIGNA VALORES ORIGINALES PARA GUARDAR
|
||||
AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total)
|
||||
|
||||
End If
|
||||
TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString
|
||||
|
||||
Dim drMon As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format(" (Abreviatura LIKE '%{0}%' OR Moneda LIKE '%{0}%' )", Moneda))
|
||||
|
||||
|
||||
Dim SbValRet As New StringBuilder
|
||||
For Each concepto As XmlNode In nodeconceptos
|
||||
' Obtener la descripción del concepto
|
||||
Dim descripcion As String = ValorXML(concepto, "Descripcion")
|
||||
Dim importeValue As Decimal = Decimal.Parse(ValorXML(concepto, "Importe"))
|
||||
|
||||
' Seleccionar el nodo de Impuestos dentro de Concepto, si existe
|
||||
Dim impuestosNode As XmlNode = concepto.SelectSingleNode("cfdi:Impuestos", namespaces)
|
||||
|
||||
If Not impuestosNode Is Nothing Then
|
||||
' Seleccionar los nodos de Retencion dentro de Impuestos
|
||||
Dim retenciones As XmlNodeList = impuestosNode.SelectNodes("cfdi:Retenciones/cfdi:Retencion", namespaces)
|
||||
For Each retencion As XmlNode In retenciones
|
||||
' Obtener los valores de los atributos Base e Importe
|
||||
Dim baseValue As Decimal = Decimal.Parse(ValorXML(retencion, "Base"))
|
||||
Dim impuesto As String = ValorXML(retencion, "Impuesto")
|
||||
|
||||
If impuesto = "001" Then
|
||||
impuesto = "Retención ISR"
|
||||
ElseIf impuesto = "002" Then
|
||||
impuesto = "Retención IVA"
|
||||
ElseIf impuesto = "003" Then
|
||||
impuesto = "IEPS"
|
||||
End If
|
||||
|
||||
|
||||
' Validar si Base coincide con Importe
|
||||
If baseValue <> importeValue Then
|
||||
'SbValRet.Append($"La base e importe de la retención del impuesto {impuesto} no coinciden para {descripcion}. Base: {baseValue.ToString()}, Importe: {importeValue.ToString()} <br>")
|
||||
SbValRet.Append($"Producto: {descripcion} La base e importe del impuesto {impuesto} no coincide Base: {baseValue.ToString()}, Importe Producto: {importeValue.ToString()} <br>")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
|
||||
If SbValRet.ToString.Trim.Length > 0 Then
|
||||
Alert(SbValRet.ToString, TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Else
|
||||
CargaConceptosXML(XMLDoc)
|
||||
End If
|
||||
|
||||
Select Case TipoComprobante
|
||||
Case "ingreso" : DdlTipoComprobante.SelectedValue = "Fac" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV"))
|
||||
Case "egreso" : DdlTipoComprobante.SelectedValue = "NC" : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac")) : DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant")) : ChkAplicaNotaCredito.Enabled = False
|
||||
Case "I"
|
||||
DdlTipoComprobante.SelectedValue = "Fac"
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV"))
|
||||
DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("6"))
|
||||
DdlTipoCompra.Items.Remove(DdlTipoCompra.Items.FindByValue("11"))
|
||||
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then DdlTipoCompra.Items.Add(New ListItem("Recolección", "14"))
|
||||
Case "E"
|
||||
DdlTipoComprobante.SelectedValue = "NC"
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Fac"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("Ant"))
|
||||
ChkAplicaNotaCredito.Enabled = False
|
||||
|
||||
DdlTipoCompra.Items.Clear()
|
||||
DdlTipoCompra.Items.Add(New ListItem("Seleccione", "-1"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("NC Con Productos", "6"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("NC Por Devolución", "11"))
|
||||
DdlTipoCompra.Items.Add(New ListItem("Garantía", "12"))
|
||||
Case "T"
|
||||
DdlTipoCompra.Items.Clear()
|
||||
DdlTipoCompra.Items.Add(New ListItem("Apoyo Logístico", "9"))
|
||||
DdlTipoComprobante.SelectedValue = "Fac"
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("NC"))
|
||||
DdlTipoComprobante.Items.Remove(DdlTipoComprobante.Items.FindByValue("DEV"))
|
||||
|
||||
End Select
|
||||
|
||||
'DIV ALIAS
|
||||
CargaPSAlias()
|
||||
|
||||
RFC = dr("RFCDe").ToString
|
||||
RFCProveedor = RFC
|
||||
TxtFecha.Text = dr("FechaFactura").ToString.ToDate.ToShortDateString
|
||||
TxtSerie.Text = dr("Serie").ToString
|
||||
TxtFolio.Text = dr("Folio").ToString
|
||||
DdlValidadaSAT.SelectedValue = If(dr("FueValidado").ToString.Contiene("Si", "1"), "Si", "No")
|
||||
DdlValidadaSAT.Enabled = False
|
||||
LblTipoFact.Text = dr("TipoFactura").ToString
|
||||
SerieVieja = dr("Serie").ToString
|
||||
LblMetodoPago.Text = MetodoPago
|
||||
|
||||
Dim SubTotal2, IVA, IEPS As Decimal
|
||||
IVA = TrasladoIVA
|
||||
|
||||
If Not UsuarioActual.TienePermisoProceso(130) Then
|
||||
TxtFolio.Enabled = False
|
||||
TxtSerie.Enabled = False
|
||||
End If
|
||||
|
||||
'PERMISO PARA MODIFICACIÓN DE FECHA AUN CON FACTURA
|
||||
TxtFecha.Enabled = UsuarioActual.TienePermisoProceso(216)
|
||||
ImgFecha.Enabled = UsuarioActual.TienePermisoProceso(216)
|
||||
CEFecha.Enabled = UsuarioActual.TienePermisoProceso(216)
|
||||
|
||||
TxtSubTotal.Enabled = False
|
||||
TxtDescuento.Enabled = False
|
||||
TxtSubTotal2.Enabled = False
|
||||
TxtIVA.Enabled = False
|
||||
TxtTotal.Enabled = False
|
||||
DdlProveedor.Enabled = False
|
||||
|
||||
If TxtFolio.Text.Trim = "" Then TxtFolio.Enabled = True : TxtSerie.Enabled = True
|
||||
|
||||
If UsuarioActual.TienePermisoProceso(112) Then
|
||||
PermisoEdicionManual = True
|
||||
TxtSubTotal.Enabled = True
|
||||
TxtDescuento.Enabled = True
|
||||
TxtSubTotal2.Enabled = True
|
||||
TxtIVA.Enabled = True
|
||||
TxtTotal.Enabled = True
|
||||
End If
|
||||
|
||||
If UsuarioActual.Empresa.Funcionalidad(118) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Fac" Then
|
||||
VerVales.Visible = True
|
||||
End If
|
||||
|
||||
If TieneAnticiposXML Then 'si tiene anticipos, limpia los descuentos
|
||||
'LblAmortizacion.Text = ImporteAnticipo.FormatoNumero
|
||||
TxtDescuento.Text = "0.00"
|
||||
LblAmortizacion.Text = Descuentos.FormatoNumero
|
||||
'limpia los descuentos
|
||||
For Each drr As DataRow In TmpDT.Rows
|
||||
'drr("Total") = drr("Total").ToString.ToDecimal + drr("Descuento").ToString.ToDecimal
|
||||
drr("Amortizacion") = drr("Descuento") 'pasamos el importe de descuento a amortizacion
|
||||
drr("Descuento") = 0.00
|
||||
Next
|
||||
Amortizaciones = Descuentos
|
||||
Descuentos = 0
|
||||
End If
|
||||
|
||||
Dim Msg As String = ""
|
||||
If Version = "3.3" Or Version = "4.0" Then
|
||||
|
||||
If Not TmpDT.Columns.Contains("Amortizacion") Then
|
||||
TmpDT.Columns.Add("Amortizacion", GetType(Decimal))
|
||||
End If
|
||||
TmpDT.AcceptChanges()
|
||||
ValidacionesTotalesXml()
|
||||
Else
|
||||
'PRUEBA
|
||||
'http://rm/Compras/Compras.aspx?CveFactura=122518 Emp: 48
|
||||
|
||||
'tTotal = Math.Round(SubTotal2 + IVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos, 2)
|
||||
HdnCompraSaldo.Value = Total.ToString
|
||||
CompraSaldo = Total
|
||||
Dim AjustaUltimoConcepto As Boolean = False
|
||||
|
||||
'AGREGA IEPS COMO CONCEPTO
|
||||
If TrasladoIEPS > 0 And UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero > 0 Then
|
||||
AgregarConceptoIEPS(TrasladoIEPS, UsuarioActual.Empresa.Funcionalidad(112).ToString.ToEntero)
|
||||
' TrasladoIEPS = 0
|
||||
End If
|
||||
'en otro impuesto lo esta registrando en ajuste en automatico
|
||||
If OtrosImpuestos > 0 Then
|
||||
AjustaUltimoConcepto = True
|
||||
End If
|
||||
|
||||
If RFC = "CFE370814QI0" Then ' RFC de CFE, se hace un ajuste por diferencia para sacar el DAP
|
||||
'OtrosImpuestos = Total - (SubTotal2 + IVA)
|
||||
'este importe lo vamos a meter al gasto
|
||||
'AjustaImporteUltimoConcepto(OtrosImpuestos)
|
||||
OtrosImpuestos = 1
|
||||
AjustaUltimoConcepto = True
|
||||
'SubTotal2 = SubTotal
|
||||
End If
|
||||
|
||||
Dim SubTotalReal As Decimal = 0
|
||||
SubTotalReal = Math.Round(Total + RetencionISR + RetencionIVA - IVA + Descuentos - TrasladoIEPS, 2) ' NO se incluye otros impuestos para ajustar esa cifra
|
||||
Dim DiferenciaTotales As Decimal = SubTotalReal - Math.Round(SubTotalConceptos, 2)
|
||||
|
||||
If DiferenciaTotales <> 0 Then
|
||||
'Verificamos IEPS y Otros Impuestos
|
||||
'restricccion general, que si el subtotal de los conceptos no cuadra con Total + RetISR + RetIVA - IVA <> SubTotalConeptos, ajuste al final
|
||||
If TrasladoIEPS > 0 OrElse OtrosImpuestos > 0 OrElse Math.Abs(DiferenciaTotales) < 1 Then
|
||||
|
||||
'Condicion necesaria cuando hay IVA pero no hay diferencia
|
||||
If DiferenciaTotales <> 0 Then
|
||||
|
||||
If DiferenciaTotales < 50 OrElse AjustaUltimoConcepto = True Then
|
||||
Dim IA As Decimal = Total + RetencionISR + RetencionIVA - IVA - SubTotalConceptos - TrasladoIEPS + Descuentos
|
||||
AjustaImporteUltimoConcepto(IA, True)
|
||||
|
||||
ElseIf DiferenciaTotales > 50 Then
|
||||
PnlAjusteProductos.Visible = True
|
||||
Dim Porcentaje As Double = Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2)
|
||||
TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero
|
||||
Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente <br>")
|
||||
ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False
|
||||
|
||||
'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias
|
||||
For Each Row As GridViewRow In GvPS.Rows
|
||||
Row.FCLinkButton("imgE").Visible = False
|
||||
Row.FCLinkButton("imgD").Visible = False
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
TrasladoIEPS = 0 : OtrosImpuestos = 0 : SubTotal2 = SubTotal
|
||||
Else
|
||||
PnlAjusteProductos.Visible = True
|
||||
Dim Porcentaje As Double = If(SubTotalConceptos > 0, Math.Round((SubTotalConceptos - SubTotalReal) / SubTotalConceptos * 100, 2), 0)
|
||||
TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero
|
||||
Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente <br>")
|
||||
ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False
|
||||
|
||||
'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias
|
||||
For Each Row As GridViewRow In GvPS.Rows
|
||||
Row.FCLinkButton("imgE").Visible = False
|
||||
Row.FCLinkButton("imgD").Visible = False
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
'Si no hay diferencias pero tenemos descuento, se ofrece la opcion para ajustar el gasto
|
||||
If Descuentos > 0 Then
|
||||
|
||||
'[IPP] PARCHE: Factura TELMEX para APH 12/ENERO/2018
|
||||
If CveFactura = 286290 Then
|
||||
|
||||
Else
|
||||
PnlAjusteProductos.Visible = True
|
||||
Dim Porcentaje As Double = Math.Round((Descuentos) / (SubTotalConceptos) * 100, 4)
|
||||
TxtAjustePorcentaje.Text = Porcentaje.FormatoNumero(4)
|
||||
Msg &= String.Format("La Factura presenta anomalias en los importes mostrados, estas anomalias impiden que se editen las partidas. Por favor realice el ajuste correspondiente <br>")
|
||||
ImgBtnBuscarOC.Visible = False : TxtOC.Enabled = False
|
||||
|
||||
'Ocultamos la opcion de Editar y Eliminar hasta que se arreglen las anomalias
|
||||
For Each Row As GridViewRow In GvPS.Rows
|
||||
Row.FCLinkButton("imgE").Visible = False
|
||||
Row.FCLinkButton("imgD").Visible = False
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
SubTotal2 = SubTotalReal - Descuentos
|
||||
|
||||
If Descuentos > 0 Then
|
||||
TrDescuento.Visible = True
|
||||
End If
|
||||
|
||||
If Msg <> "" Then
|
||||
Alert(Msg, TipoMensaje.MsgAdvertencia)
|
||||
BtnGuardar.Enabled = False
|
||||
End If
|
||||
'AJUSTAMOS SUBTOTAL EN CASO DE SER DIFERENTE AL SUBTOTAL2 DEL XML (TOTAL - IVA)
|
||||
If SubTotal2 <> SubTotal Then
|
||||
SubTotal = SubTotalConceptos
|
||||
End If
|
||||
|
||||
TxtSubTotal.Text = SubTotal.FormatoNumero
|
||||
TxtDescuento.Text = Descuentos.FormatoNumero
|
||||
TxtSubTotal2.Text = SubTotal2.FormatoNumero
|
||||
TxtIVA.Text = IVA.FormatoNumero
|
||||
TxtTotal.Text = Total.ToString.FormatoNumero
|
||||
|
||||
HfTotalCompra.Value = Total.ToString
|
||||
CompraSaldo = Total
|
||||
|
||||
CalculaTotalPorDevengar()
|
||||
TxtDocumentoImporteFE.Text = Total.ToString
|
||||
RVDocumentoImporte.MaximumValue = Math.Round(Total, 2).ToString
|
||||
RVDocumentoImporteFE.MaximumValue = RVDocumentoImporte.MaximumValue
|
||||
RVDocumentoImporteCaja.MaximumValue = RVDocumentoImporte.MaximumValue
|
||||
TxtDocumentoImporte.Text = Total.FormatoNumero
|
||||
TxtDocumentoImporteCaja.Text = Total.FormatoNumero
|
||||
TxtRetIVA.Text = RetencionIVA.FormatoNumero
|
||||
TxtRetISR.Text = RetencionISR.FormatoNumero
|
||||
TxtIEPS.Text = IEPS.FormatoNumero
|
||||
If IEPS > 0 Then TrIEPS.Visible = True
|
||||
If RetencionIVA > 0 Then TrRetIVA.Visible = True
|
||||
If RetencionISR > 0 Then TrRetISR.Visible = True
|
||||
TxtOtrosImpuestos.Text = OtrosImpuestos.FormatoNumero
|
||||
If OtrosImpuestos > 0 Then TrOtrosImpuestos.Visible = True
|
||||
|
||||
HFDiferenciaCompra.Value = TxtTotal.Text
|
||||
'ASIGNA VALORES ORIGINALES PARA GUARDAR
|
||||
AsignaValoresOriginales(SubTotal, SubTotal2, IVA, RetencionIVA, RetencionISR, Total)
|
||||
|
||||
End If
|
||||
TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString
|
||||
|
||||
Dim drMon As DataRow = GlobalDTMonedas.FiltroPrimero(String.Format(" (Abreviatura LIKE '%{0}%' OR Moneda LIKE '%{0}%' )", Moneda))
|
||||
|
||||
If drMon IsNot Nothing Then
|
||||
DdlMoneda.SelectedValue = drMon("CveMoneda").ToString
|
||||
CveMoneda = drMon("CveMoneda").ToString.ToEntero
|
||||
Else
|
||||
'sino busco en la tabla de alias
|
||||
drMon = GlobalDTMonedasAlias.FiltroPrimero(String.Format("MonedaAlias LIKE '%{0}%' ", Moneda))
|
||||
|
||||
If drMon IsNot Nothing Then
|
||||
DdlMoneda.SelectedValue = drMon("CveMoneda").ToString
|
||||
CveMoneda = drMon("CveMoneda").ToString.ToEntero
|
||||
Else
|
||||
'sino busco en la tabla de alias
|
||||
drMon = GlobalDTMonedasAlias.FiltroPrimero(String.Format("MonedaAlias LIKE '%{0}%' ", Moneda))
|
||||
|
||||
If drMon IsNot Nothing Then
|
||||
DdlMoneda.SelectedValue = drMon("CveMoneda").ToString
|
||||
CveMoneda = drMon("CveMoneda").ToString.ToEntero
|
||||
Else
|
||||
LblMoneda.Text = Moneda
|
||||
LblMoneda.ForeColor = Drawing.Color.Red
|
||||
End If
|
||||
End If
|
||||
|
||||
If DdlMoneda.SelectedValue.ToEntero > 1 Then
|
||||
If TipoCambio <= 10 Then
|
||||
TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
|
||||
End If
|
||||
|
||||
TxtFecha.Attributes.Remove("onblur")
|
||||
If UsuarioActual.Empresa.UsaAC Then
|
||||
TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();")
|
||||
Else
|
||||
TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();")
|
||||
End If
|
||||
End If
|
||||
|
||||
If TipoCambio > 0 And DdlMoneda.SelectedValue.ToEntero > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4"))
|
||||
|
||||
'DF - 10-04-17
|
||||
If UsuarioActual.TienePermisoProceso(187) Then
|
||||
TxtSerie.Enabled = True
|
||||
End If
|
||||
|
||||
If LblMetodoPago.Text = "" AndAlso TipoComprobante <> "T" Then
|
||||
Alert("El xml no contiene la etiqueta 'método de pago', favor de verificar la emisión con el proveedor.", TipoMensaje.MsgAdvertencia)
|
||||
BtnGuardar.Visible = False
|
||||
LblMoneda.Text = Moneda
|
||||
LblMoneda.ForeColor = Drawing.Color.Red
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
|
||||
If DdlMoneda.SelectedValue.ToEntero > 1 Then
|
||||
If TipoCambio <= 10 Then
|
||||
TipoCambio = GlobalTipoCambio(TxtFecha.Text.ToDate).ToDecimal
|
||||
End If
|
||||
|
||||
TxtFecha.Attributes.Remove("onblur")
|
||||
If UsuarioActual.Empresa.UsaAC Then
|
||||
TxtFecha.Attributes.Add("onblur", "CambiaFecha();CambiaFechaTC();")
|
||||
Else
|
||||
TxtFecha.Attributes.Add("onblur", "CambiaFechaTC();")
|
||||
End If
|
||||
End If
|
||||
|
||||
If TipoCambio > 0 And DdlMoneda.SelectedValue.ToEntero > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4"))
|
||||
|
||||
'DF - 10-04-17
|
||||
If UsuarioActual.TienePermisoProceso(187) Then
|
||||
TxtSerie.Enabled = True
|
||||
End If
|
||||
|
||||
If LblMetodoPago.Text = "" AndAlso TipoComprobante <> "T" Then
|
||||
Alert("El xml no contiene la etiqueta 'método de pago', favor de verificar la emisión con el proveedor.", TipoMensaje.MsgAdvertencia)
|
||||
BtnGuardar.Visible = False
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Alert("No se Encontró la Factura", TipoMensaje.MsgAdvertencia)
|
||||
BtnGuardar.Visible = False
|
||||
End If
|
||||
@@ -3549,12 +3549,23 @@ Partial Class Compras_Compras
|
||||
ViewState("CveProveedor") = ObjProveedor.CveProveedor
|
||||
HdnCveProveedor.Value = ObjProveedor.CveProveedor.ToString
|
||||
TxtFechaPago.Text = (TxtFecha.Text.ToDate.AddDays(LblDiasCredito.Text.ToEntero)).ToShortDateString
|
||||
RFCProveedor = ObjProveedor.RFC
|
||||
'comentado RMF.2024.05.21. en anticipos parciales, está bloquenado
|
||||
'If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 Then
|
||||
|
||||
CveRegimenFiscalProveedor = ObjProveedor.CveRegimenFiscal
|
||||
If CveFactura > 0 Then
|
||||
' Dim ImporteAnticipoComision As Decimal = 0
|
||||
' If ArrAnticipos.Count > 0 Then
|
||||
' For Each Ant As Compras_Compras.Anticipos In ArrAnticipos
|
||||
' ImporteAnticipoComision += Ant.ImporteComision
|
||||
' Next
|
||||
' End If
|
||||
|
||||
If RetIVAOriginal > 0 Then
|
||||
' If (LblSaldoFactura.Text.ToDecimal - ImporteAnticipoComision) > 0 Then
|
||||
' Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If RetIVAOriginal > 0 Then
|
||||
Dim CalRetIVAPor As Decimal = (RetIVAOriginal * 1 / SubTotal2Original).RoundAD(6).ToDecimal
|
||||
|
||||
If (CalRetIVAPor).RoundSQL(5) = 0.10666 OrElse (CalRetIVAPor).RoundSQL(5) = 0.05333 Then
|
||||
@@ -4193,21 +4204,10 @@ Partial Class Compras_Compras
|
||||
|
||||
'------------------ INICIA VALIDACIONES ------------------
|
||||
|
||||
'comentado RMF.2024.05.21. en anticipos parciales, está bloquenado
|
||||
'If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 Then
|
||||
|
||||
' Dim ImporteAnticipoComision As Decimal = 0
|
||||
' If ArrAnticipos.Count > 0 Then
|
||||
' For Each Ant As Compras_Compras.Anticipos In ArrAnticipos
|
||||
' ImporteAnticipoComision += Ant.ImporteComision
|
||||
' Next
|
||||
' End If
|
||||
|
||||
' If (LblSaldoFactura.Text.ToDecimal - ImporteAnticipoComision) > 0 Then
|
||||
' Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia)
|
||||
' Exit Sub
|
||||
' End If
|
||||
'End If
|
||||
If MetodoPagoOC = 0 AndAlso RBLPago.SelectedValue.ToEntero <> 2 AndAlso LblSaldoFactura.Text.ToDecimal > 0 Then
|
||||
Alert("La orden de compra se definió de contado, favor de especificar la compra de contado.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim CveSubProyectoPrincipal As Integer = AsignarSubProyectoPrincipal()
|
||||
|
||||
@@ -7251,20 +7251,22 @@ Partial Class Compras_Compras
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
Else
|
||||
Dim ImporteAntMNComision As Decimal = (ImporteAnt + ImporComisionAnticipo) * TipoCambioAnt
|
||||
'Dim ImporteAntMNComision As Decimal = (ImporteAnt + ImporComisionAnticipo) * TipoCambioAnt
|
||||
Dim ImporteAntMNComision As Decimal = (ImporteAnt) * TipoCambioAnt
|
||||
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, (ImporteAnt + ImporComisionAnticipo), ImporteAntMNComision, ConceptoContableAnticipo, Referencia, Concepto, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveIE:=Ant.CveIE, ImporteME:=If(tipoCambioActual = 1, 0, (ImporteAnt + ImporComisionAnticipo)), TipoCambio:=TipoCambioAnt, Contabilizable:=SeContabiliza) Then
|
||||
'If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, (ImporteAnt + ImporComisionAnticipo), ImporteAntMNComision, ConceptoContableAnticipo, Referencia, Concepto, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveIE:=Ant.CveIE, ImporteME:=If(tipoCambioActual = 1, 0, (ImporteAnt + ImporComisionAnticipo)), TipoCambio:=TipoCambioAnt, Contabilizable:=SeContabiliza) Then
|
||||
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, (ImporteAnt), ImporteAntMNComision, ConceptoContableAnticipo, Referencia, Concepto, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveIE:=Ant.CveIE, ImporteME:=If(tipoCambioActual = 1, 0, (ImporteAnt)), TipoCambio:=TipoCambioAnt, Contabilizable:=SeContabiliza) Then
|
||||
ErrorPrepoliza = True
|
||||
End If
|
||||
End If
|
||||
If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then
|
||||
|
||||
Dim Pago As New CompraPago
|
||||
Pago.ImportePago = importeMovimiento
|
||||
Pago.ImportePago = importeMovimiento + ImporComisionAnticipo
|
||||
Pago.CveIE = Ant.CveIE
|
||||
Pago.TCPago = Ant.TCCompra
|
||||
Pago.CveMonedaPago = If(Ant.TCCompra > 1, 2, 1)
|
||||
Pago.OtroGastoIngreso = ImporComisionAnticipo
|
||||
Pago.OtroGastoIngreso = -ImporComisionAnticipo
|
||||
ErrorPrepoliza = AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjConta)
|
||||
|
||||
End If
|
||||
@@ -8491,7 +8493,8 @@ Partial Class Compras_Compras
|
||||
Dim ImporteAnticipo As Decimal = 0
|
||||
If ArrAnticipos.Count > 0 Then
|
||||
For Each Ant As Compras_Compras.Anticipos In ArrAnticipos
|
||||
ImporteAnticipo += Ant.Importe
|
||||
'ImporteAnticipo += (Ant.Importe + Ant.ImporteComision)
|
||||
ImporteAnticipo += (Ant.Importe)
|
||||
Next
|
||||
End If
|
||||
|
||||
@@ -9773,22 +9776,30 @@ Partial Class Compras_Compras
|
||||
Dim tTCFecha As Double = If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble)
|
||||
|
||||
|
||||
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2},{3},{4},{5},{6});",
|
||||
|
||||
|
||||
|
||||
|
||||
If UsuarioActual.Empresa.CveEmpresa.Contiene(13, 83) Then
|
||||
|
||||
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2},{3},{4},{5},{6},{7});",
|
||||
e.Row.FCTextBox("TxtAnticipo").ClientID,
|
||||
e.Row.DBCampo("Saldo"),
|
||||
If(CveCompra > 0, CompraSaldo, ImporteAmortizacion),
|
||||
e.Row.DBCampo("CveMoneda"),
|
||||
e.Row.DBCampo("TCCompra").ToDouble,
|
||||
DdlMoneda.SelectedValue,
|
||||
IIf(DdlMoneda.SelectedValue = "1", 1, TxtTC.Text))) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
|
||||
IIf(DdlMoneda.SelectedValue = "1", 1, TxtTC.Text),
|
||||
e.Row.FCTextBox("TxtComision").ClientID
|
||||
)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
|
||||
|
||||
|
||||
|
||||
If UsuarioActual.Empresa.CveEmpresa.Contiene(13, 83) Then
|
||||
e.Row.FCTextBox("TxtAnticipo").Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1},{2},{3},{4},{5},{6});",
|
||||
e.Row.FCCheckBox("Chk").ClientID,
|
||||
e.Row.DBCampo("Saldo"),
|
||||
If(CveCompra > 0, CompraSaldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero,
|
||||
If(CveCompra > 0, CompraSaldo, ImporteAmortizacion),
|
||||
e.Row.DBCampo("CveMoneda").ToEntero,
|
||||
tTCFecha,
|
||||
DdlMoneda.SelectedValue.ToEntero,
|
||||
e.Row.FCTextBox("TxtComision").ClientID)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
|
||||
@@ -9802,6 +9813,17 @@ Partial Class Compras_Compras
|
||||
DdlMoneda.SelectedValue.ToEntero,
|
||||
e.Row.FCTextBox("TxtAnticipo").ClientID))
|
||||
Else
|
||||
|
||||
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2},{3},{4},{5},{6});",
|
||||
e.Row.FCTextBox("TxtAnticipo").ClientID,
|
||||
e.Row.DBCampo("Saldo"),
|
||||
If(CveCompra > 0, CompraSaldo, ImporteAmortizacion),
|
||||
e.Row.DBCampo("CveMoneda"),
|
||||
e.Row.DBCampo("TCCompra").ToDouble,
|
||||
DdlMoneda.SelectedValue,
|
||||
IIf(DdlMoneda.SelectedValue = "1", 1, TxtTC.Text)
|
||||
)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
|
||||
|
||||
e.Row.FCTextBox("TxtAnticipo").Attributes.Add("onKeyUp", String.Format("FnCambiaAnt({0},this,{1},{2},{3},{4},{5});",
|
||||
e.Row.FCCheckBox("Chk").ClientID,
|
||||
e.Row.DBCampo("Saldo"),
|
||||
|
||||
Reference in New Issue
Block a user