-- cambio de vinculacion de anticipos por descuento

This commit is contained in:
2020-02-19 18:19:34 -07:00
parent 3de28635b0
commit 8cee05c181

View File

@@ -104,6 +104,15 @@ Partial Class Compras_Compras
Set(ByVal value As List(Of String))
ViewState("ListaDocumentos") = value
End Set
End Property
Public Property TieneAnticiposXML As Boolean
Get
TieneAnticiposXML = DirectCast(ViewState("TieneAnticiposXML"), Boolean)
End Get
Set(ByVal value As Boolean)
ViewState("TieneAnticiposXML") = value
End Set
End Property
Private Property DTOCTemp As DataTable
@@ -873,6 +882,7 @@ Partial Class Compras_Compras
Private Property Descuentos As Decimal = 0
Private Property Amortizaciones As Decimal = 0
Private Property EmisorRFC As String
Private Property ReceptorRFC As String
Private Property TrasladoIVA As Decimal = 0
@@ -1116,6 +1126,7 @@ Partial Class Compras_Compras
'ImgBtnBuscarOC.Attributes.Add("data-toggle", "tooltip")
'ImgBtnBuscarOC.Attributes.Add("data-placement", "top")
CargaDatosAgregarPS()
TieneAnticiposXML = False
Modalidad = ""
Version = ""
CveMetodoPago = -1
@@ -1405,13 +1416,12 @@ Partial Class Compras_Compras
End If
'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
LblSaldoFactura.Text = If(CveCompra > 0, Saldo.FormatoNumero, TxtTotal.Text.FormatoNumero)
'cuando es factura con amortizacion, el importe a descontar es el saldo que se debe de aplicar para la amortizacion
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 Then
LblSaldoFactura.Text = TmpDT.SUMD("Descuento").ToString
LblSaldoFactura.Text = If(CveCompra > 0, Saldo.FormatoNumero, TxtTotal.Text.FormatoNumero)
'cuando es factura con amortizacion, el importe a descontar es el saldo que se debe de aplicar para la amortizacion
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 Then
LblSaldoFactura.Text = TmpDT.SUMD("Descuento").ToString
End If
If UsuarioActual.CveEmpresa = 126 And CveCompra > 0 Then
LnkExportaGv.Visible = True
End If
@@ -1833,6 +1843,20 @@ Partial Class Compras_Compras
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 = ""
@@ -2131,7 +2155,7 @@ Partial Class Compras_Compras
Private Sub ValidacionesTotalesXml()
Dim Msg As String = ""
Dim SubtotalTemp = TmpDT.SUM("Total") + Math.Round(TmpDT.SUM("Descuento"), 2)
Dim SubtotalTemp = TmpDT.SUM("Total") + Math.Round(TmpDT.SUM("Descuento") + Math.Round(TmpDT.SUM("Amortizacion")), 2)
Dim DescuentosTemp = TmpDT.SUM("Descuento")
Dim Subtotal2Temp = TmpDT.SUM("Total")
Dim IVATemp = TmpDT.SUM("IVA")
@@ -4373,7 +4397,7 @@ Partial Class Compras_Compras
'METODO DE PREPOLIZA DE ALMACEN
If UsuarioActual.CveEmpresa.Contiene(1, 119, 72, 80) And UsuarioActual.Empresa.UsaInventarios And Not UsuarioActual.Empresa.Funcionalidad(126) = "1" Then
Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal
Dim ImporteAlmacen = TmpDT.SUM(If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0, "ImporteSinImpuestos", "Total"), $"ISNULL(TipoAF,0) <> 2 AND ISNULL(CveAlmacen,0) = 0 AND ISNULL(AplicaCostoIndirecto,0) <> 1 AND CveTipoPS = 2").ToString.ToDecimal
If ImporteAlmacen > 0 Then
If Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
If (CveImportacion > 0 Or CveFlete > 0) Then
@@ -4406,19 +4430,19 @@ Partial Class Compras_Compras
CveEstatusFactura = 6
End If
'hay amortización directa como descuento. RMF Temporal
'If UsuarioActual.CveEmpresa = 119 Then
' If LblAmortizacion.Text.ToDouble > 0 AndAlso TxtDescuento.Text.ToDouble = 0 Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
' End If
If UsuarioActual.CveEmpresa = 119 Then
'If LblAmortizacion.Text.ToDouble > 0 AndAlso TxtDescuento.Text.ToDouble = 0 Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
'End If
' 'o si el descuento es igual a la amortizacion
' If LblAmortizacion.Text.ToDouble = TxtDescuento.Text.ToDouble Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
' End If
'o si el descuento es igual a la amortizacion
'If LblAmortizacion.Text.ToDouble = TxtDescuento.Text.ToDouble Then
' TxtDescuento.Text = LblAmortizacion.Text
' LblAmortizacion.Text = "0.00"
'End If
'End If
End If
'Compra
If ObjCompras.AddCompra(DdlTipoComprobante.SelectedValue, TxtDescripcion.Text.Trim, TxtSerie.Text.Trim, TxtFolio.Text.Trim, TxtFolioSecundario.Text.Trim, CveProveedor, TxtSubTotal.Text.ToDouble, TxtDescuento.Text.ToDouble,
@@ -5865,6 +5889,11 @@ Partial Class Compras_Compras
End If
If UsuarioActual.Empresa.Funcionalidad(577).ToEntero = 1 Then
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(578).ToEntero
End If
'Agregamos el Opuesto del 22 -> 15
If importeMovimiento <> 0 Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 15, Concepto + If(tipoCambioActual > 1, $" TC: {tipoCambioActual} ${importeMovimiento.FormatoNumero(2)}", ""), FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveAcreedor:=CveAcreedor, CveIE:=CveIE, CvePersonal:=CvePersonal, CveColectiva:=CveColectiva, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMovimiento * tipoCambioActual, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, Contabilizable:=SeContabiliza, TipoCambio:=tipoCambioActual) Then
@@ -6181,33 +6210,31 @@ Partial Class Compras_Compras
Else
importeMovimiento = 0
End If
Case 285 'Ret IVA 6% Servicios
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(578).ToEntero
'If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
' If ObjConta.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
' CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
' End If
'End If
If DdlRetIVAConcepto.SelectedValue.ToEntero = 5 Then
If CveMoneda = 2 Then
importeMN = TmpDT.SUMD("RetIVA") * TxtTC.Text.ToDecimal
Else
importeMN = TmpDT.SUMD("RetIVA")
importeMovimiento = TmpDT.SUMD("RetIVA")
End If
Else
importeMovimiento = 0
Case 285 'Ret IVA 6% Servicios
IdCtaContable = UsuarioActual.Empresa.Funcionalidad(578).ToEntero
'If ObjConta.GetRetCuenta(ConceptoContable, UsuarioActual.CveEmpresa) And Not IdCtaContable > 0 Then
' If ObjConta.DtResultados.Rows.Count > 0 Then
' IdCtaContable = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacion").ToString.ToEntero
' CveCuenta = ObjConta.DtResultados.Rows(0)("IdCuentaRetIVACirculacionSIG").ToString.ToEntero
' End If
'End If
If DdlRetIVAConcepto.SelectedValue.ToEntero = 5 Then
If CveMoneda = 2 Then
importeMN = TmpDT.SUMD("RetIVA") * TxtTC.Text.ToDecimal
Else
importeMN = TmpDT.SUMD("RetIVA")
importeMovimiento = TmpDT.SUMD("RetIVA")
End If
Else
importeMovimiento = 0
End If
Case 6 'Compra
Dim AgregaMercanciaInventario As Boolean = UsuarioActual.CveEmpresa.Contiene(1, 72, 80, 119) AndAlso UsuarioActual.Empresa.UsaInventarios AndAlso Not UsuarioActual.Empresa.Funcionalidad(126) = "1"
@@ -6787,6 +6814,7 @@ Partial Class Compras_Compras
Else
ErrorPrepoliza = True
Exit For
Exit For
End If
' FLUCTUACION CAMBIARIA
@@ -7017,7 +7045,7 @@ Partial Class Compras_Compras
Exit For
End If
If TxtTotal.Text.ToDouble > 0 Then
If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then
importeMNNC = importeMovimientoNC * tipoCambioActual * Multiplicador
IdCtaContable = CtaProveedorExtranjera ' CtaProveedorAnticiposExtranjera
CveCuenta = CveCuentaProveedorExtranjera 'CveCuentaProveedorAnticiposExtranjera
@@ -7119,7 +7147,7 @@ Partial Class Compras_Compras
ErrorPrepoliza = True
End If
If TxtTotal.Text.ToDouble > 0 Then
If TxtTotal.Text.ToDouble > 0 AndAlso TieneAnticiposXML = False Then
Dim IdCtaContablePago As Integer = CtaProveedor
Dim CveCuentaPago As Integer = CveCuentaProveedor
Dim usacomplementariaProveedor As Boolean = False
@@ -7180,15 +7208,19 @@ Partial Class Compras_Compras
Dim PorcentajePagoAnt As Decimal = importeMovimiento / If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal)
Dim ImporteIVA As Decimal = Math.Round(PorcentajePagoAnt * TxtIVA.Text.ToDecimal, 2)
'Agregamos el 14
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
'Agregamos el 19
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
If ImporteIVA <> 0 Then
'Agregamos el 14
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteIVA, Referencia, 14, Concepto, FechaMovimiento, CtaIvaxAcreditar, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), CveCuenta:=CveCuentaIvaxAcreditar, PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
'Agregamos el 19
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, ImporteIVA, Referencia, 19, Concepto, FechaMovimiento, CtaIvaAcreditable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=ImporteIVA * tipoCambioActual * Multiplicador, ImporteME:=If(tipoCambioActual = 1, 0, ImporteIVA), PorcentajeImpuesto:=PorcentajeImpuestoAnticipo, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
End If
End If
@@ -7493,10 +7525,11 @@ Partial Class Compras_Compras
End Select
If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Ant.Importe, " ", CveConceptoAnt, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
' ImporteAnticipo += Ant.Importe ' RESTO DEL IMPORTE POR SI QUEDA DIFERENCIA DE LA SUMA DE LOS ANTICIPOS Y EL PROVEEDOR TIENE QUE PAGAR
'movimiento de pago proveedor, --no se regisra porque no se registra el total de la compra como deuda del proveedor, solo lo que queda a deber
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, Ant.Importe, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Ant.Importe, " ", CveConceptoAnt, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompraNC, CveCompraAmortizacion:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
' ImporteAnticipo += Ant.Importe ' RESTO DEL IMPORTE POR SI QUEDA DIFERENCIA DE LA SUMA DE LOS ANTICIPOS Y EL PROVEEDOR TIENE QUE PAGAR
'movimiento de pago proveedor, --no se regisra porque no se registra el total de la compra como deuda del proveedor, solo lo que queda a deber
'si es l moviemiento es de amortizacion con descuento, no registra el pago, ya esta descontado
If TieneAnticiposXML = False AndAlso Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimientoCompra, Ant.Importe, " ", CveConceptoPago, " ", TxtFechaPago.Text.ToDate, 0, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorLocal, CveAcreedor:=CveAcreedor, CveIE:=Ant.CveIE, CveColectiva:=CveColectiva, ImporteMX:=Ant.Importe) Then
ErrorMovtosCxP = True
End If
PorcentajePago = (Ant.Importe) / TxtTotal.Text.ToDecimal
@@ -9060,12 +9093,8 @@ Partial Class Compras_Compras
Next
End If
LblAmortizacion.Text = ImporteAnticipo.FormatoNumero
TxtDescuento.Text = "0.00"
'limpia los descuentos
For Each dr As DataRow In TmpDT.Rows
dr("Descuento") = 0.00
Next
LblAmortizacion.Text = ImporteAnticipo.FormatoNumero
UpPS.Update()
End If
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAnticipos"))
@@ -10114,6 +10143,7 @@ Partial Class Compras_Compras
If documento.Attributes("UUID").Value <> "" Then
ListaDocumentos.Add(documento.Attributes("UUID").Value)
End If
TieneAnticiposXML = True
Next
End If
End If
@@ -10282,10 +10312,10 @@ Partial Class Compras_Compras
e.Row.BackColor = Drawing.Color.LightGray
Else
If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(3).ForeColor = Drawing.Color.Red
If e.Row.DBCampo("Saldo").ToDouble = 0 Then e.Row.FCLiteral("LtlAnticipos").Text = ""
If e.Row.DBCampo("Saldo").ToDouble = 0 Then e.Row.FCLiteral("LtlAnticipos").Text = ""
Dim ImporteAmortizacion As Decimal = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0, TmpDT.SUMD("ImporteConImpuestos"), TxtTotal.Text.ToDecimal)
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2});", e.Row.FCTextBox("TxtAnticipo").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("chkAnt(this,{0},{1},{2});", e.Row.FCTextBox("TxtAnticipo").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) '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});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"), If(CveCompra > 0, Saldo, ImporteAmortizacion), e.Row.DBCampo("CveMoneda").ToEntero, If(Not e.Row.DBCampo("TCCompra").ToDouble > 1, GlobalTipoCambio(e.Row.DBCampo("Fecha").ToDate), e.Row.DBCampo("TCCompra").ToDouble), DdlMoneda.SelectedValue.ToEntero)) 'SI ES UNA COMPRA NUEVA SE PONE EL TOTAL, SI NO EL SALDO
If ChkNCInv.Checked Then
@@ -10612,6 +10642,7 @@ Partial Class Compras_Compras
DTConceptos.Columns.Add("Descuento", GetType(Double))
DTConceptos.Columns.Add("IVA", GetType(Double))
DTConceptos.Columns.Add("Total", GetType(Double))
DTConceptos.Columns.Add("Amortizacion", GetType(Double))
End Sub
'Private Sub AddPS(Cantidad As Double, UM As String, PS As String, PU As Double, IVA As Double, Descuento As Double, Optional Total As Double = 0)
' Dim Row As DataRow = Nothing
@@ -11959,14 +11990,19 @@ Partial Class Compras_Compras
#End Region
#Region " AJUSTA IMPORTES "
Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False)
'Dim TempSubTotal = TxtSubTotal.Text.ToDouble
Private Sub AjustaImporteUltimoConcepto(ImporteAjuste As Decimal, Optional EsCarga As Boolean = False)
'Dim TempSubTotal = TxtSubTotal.Text.ToDouble
Dim Amortizacion As Decimal = 0
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
Amortizacion = LblAmortizacion.Text.ToDecimal
End If
If TmpDT.Rows.Count > 0 Then ' si hay movimientos y si esta afectando al total, que se haga el ajuste
'Dim ImporteAjuste As Decimal = Total - (SubTotal2 + IVA - RetencionIVA - RetencionIVA - RetencionISR + IEPS + OtrosImpuestos)
Dim Indice As Integer = If(TmpDT.Rows(TmpDT.Rows.Count - 1)("CvePS").ToString = UsuarioActual.Empresa.Funcionalidad(112).ToString, TmpDT.Rows.Count - 2, TmpDT.Rows.Count - 1)
Dim tPU As Decimal
Dim tPU As Decimal
If TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal > 0 Then
tPU = ImporteAjuste / TmpDT.Rows(Indice)("Cantidad").ToString.ToDecimal
Else
@@ -11983,7 +12019,7 @@ Partial Class Compras_Compras
Descuentos = TmpDT.SUM("Descuento").ToString.ToDecimal
End If
TxtSubTotal.Text = (SubTotal + Descuentos).FormatoNumero()
TxtSubTotal2.Text = SubTotal.FormatoNumero
TxtSubTotal2.Text = (SubTotal - Amortizacion).FormatoNumero
TxtDescuento.Text = Descuentos.FormatoNumero()
SubTotalConceptos = SubTotal
GvPS.DataSource = TmpDT : GvPS.DataBind()
@@ -14861,10 +14897,10 @@ Partial Class Compras_Compras
'If DdlOCVinculaInv.SelectedValue.ToEntero = 237 And Not CveFlete > 0 Then Alert("Necesita vincular un flete si selecciona Factura de Flete", TipoMensaje.MsgAdvertencia) : Exit Sub
'If DdlOCVinculaInv.SelectedValue.ToEntero = 240 And Not CveImportacion > 0 Then Alert("Necesita vincular una Importación si selecciona Factura de Importación", TipoMensaje.MsgAdvertencia) : Exit Sub
Dim SubTotalGV = 0.0D
Dim Amortizacion As Decimal = TmpDT.SUMD("Total")
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
Amortizacion = TmpDT.SUMD("ImporteSinImpuestos")
Dim SubTotalGV = 0.0D
Dim Amortizacion As Decimal = TmpDT.SUMD("Total")
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
Amortizacion = TmpDT.SUMD("ImporteSinImpuestos")
End If
Dim SubTotalCompra As Decimal = Amortizacion
Dim DiferenciaPermitida = 1
@@ -14933,12 +14969,14 @@ Partial Class Compras_Compras
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then
TotalRows += 1
End If
Next
Dim Amortizacion As Decimal = 0
Next
Dim TieneAmortizacion As Boolean = False
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
TieneAmortizacion = True
End If
For Each gvr As GridViewRow In GvOC1.Rows
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Or VinculacionCompleta Then
dr = DTOCGV.Rows(gvr.RowIndex)
@@ -14957,9 +14995,8 @@ Partial Class Compras_Compras
Dim SubProyecto As String = dr("SubProyecto").ToString
Dim Proyecto As String = dr("Proyecto").ToString
Dim Obs As String = dr("Obs").ToString
Dim PU As Decimal = gvr.FCTextBox("TxtPU").Text.ToDecimal
Dim Total As Decimal = If(TieneAmortizacion, Math.Round((gvr.FCTextBox("TxtCantidad").Text.ToDecimal * gvr.FCTextBox("TxtPU").Text.ToDecimal) - (TxtDescuento.Text.ToDouble / TotalRows).ToDecimal, 2), gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal)
Dim PU As Decimal = gvr.FCTextBox("TxtPU").Text.ToDecimal
Dim Total As Decimal = If(ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 AndAlso TxtTotal.Text.ToDecimal = 0, Math.Round((gvr.FCTextBox("TxtCantidad").Text.ToDecimal * gvr.FCTextBox("TxtPU").Text.ToDecimal) - (TxtDescuento.Text.ToDouble / TotalRows).ToDecimal, 2), gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal)
'Dim Total As Decimal = gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal
'Dim IVA As Decimal = gvr.FCHiddenField("HdnOC1IVA").Value.ToDecimal
'Dim RetIVA As Double = gvr.FCHiddenField("HdnOC1RetIVA").Value.ToDecimal
@@ -15020,11 +15057,10 @@ Partial Class Compras_Compras
AddPS2(False)
'AJUSTE DE REDONDEO O DIFERENCIA PERMITIDA DE IMPORTE
AjustaImporteUltimoConcepto((If(TieneAmortizacion, TmpDT.SUMD("ImporteSinImpuestos"), TxtSubTotal2.Text.ToDouble) + TxtOtrosImpuestos.Text.ToDouble).ToDecimal - If(TieneAmortizacion, TmpDT.SUM("ImporteSinImpuestos").ToString.ToDecimal, TmpDT.SUM("Total").ToString.ToDecimal))
'AjustaImporteUltimoConcepto(TxtSubTotal2.Text.ToDecimal + TxtOtrosImpuestos.Text.ToDecimal - (TmpDT.SUM("Total").ToString.ToDecimal))
AjustaImporteUltimoConcepto((If(TieneAmortizacion, TmpDT.SUMD("ImporteSinImpuestos"), TxtSubTotal2.Text.ToDouble) + TxtOtrosImpuestos.Text.ToDouble).ToDecimal - If(TieneAmortizacion, TmpDT.SUM("ImporteSinImpuestos").ToString.ToDecimal, TmpDT.SUM("Total").ToString.ToDecimal))
'AjustaImporteUltimoConcepto(TxtSubTotal2.Text.ToDecimal + TxtOtrosImpuestos.Text.ToDecimal - (TmpDT.SUM("Total").ToString.ToDecimal))
BtnGuardar.Enabled = True
If Not CierrePeriodo Then
BtnGuardar.Visible = True
@@ -16500,6 +16536,16 @@ Partial Class Compras_Compras
Dim Amortizacion As Decimal = 0
If UsuarioActual.CveEmpresa = 119 Then
Amortizacion = LblAmortizacion.Text.Trim.ToDecimal
TxtSubTotal.Text = (TxtSubTotal.Text.ToDouble + Amortizacion).ToString
End If
Dim TieneAmortizacion As Boolean = False
If ListaDocumentos IsNot Nothing AndAlso ListaDocumentos.Count > 0 AndAlso ArrAnticipos IsNot Nothing AndAlso ArrAnticipos.Count > 0 Then
TieneAmortizacion = True
End If
If CveCompra < 0 AndAlso Not TieneAmortizacion Then
LblAmortizacion.Text = "0.00"
End If
TempSubTotal = TxtSubTotal.Text.ToDouble
@@ -16511,7 +16557,7 @@ Partial Class Compras_Compras
TempIEPS = TxtIEPS.Text.ToDouble
TempRetIVA = TxtRetIVA.Text.ToDouble
TempRetISR = TxtRetISR.Text.ToDouble
TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR - TxtOtrosImpuestos.Text.ToDouble, 2)
TempTotal = Math.Round(TempSubTotal2 + TempIVA + TempIEPS - TempRetIVA - TempRetISR - TxtOtrosImpuestos.Text.ToDouble - Amortizacion, 2)
DifTotales = TxtTotal.Text.ToDouble - TempTotal
Dim DiferenciaPermitida = 0.6