diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx
index 0e84a3b80..0e1e68e12 100644
--- a/Compras/eFacturas.aspx
+++ b/Compras/eFacturas.aspx
@@ -265,10 +265,10 @@
-
Caja Chica
- Viáticos
+ Viáticos
+ Deudores
@@ -295,7 +295,7 @@
+
@@ -352,7 +353,7 @@
-
@@ -827,6 +908,134 @@
+
+ <%--PRORRATE INICIO--%>
+
+
+
+
+
+
+
+
+
+
+
+
+ <%-- --%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%--PRORRATEO FIN--%>
+
+
-
-
+
@@ -1552,9 +1760,173 @@
$('#BtnCargaCompraComplementoTraslado').click();
}
- //function VinculacionManual(v) {
- // $get("HdnCveIE").value = v;
- // $('#BtnVincularManualmente').click();
- //}
+
+ function CambioTipoMoneda() {
+
+
+ var chkPesosBancos = $get("ChkPagarPesos");
+ var chkDolaresBancos = $get("ChkPagarDolares");
+
+ AjustaTextboxDeudores();
+ if (chkPesosBancos) {
+ CambiaPesosDolares()
+ } else if (chkDolaresBancos) {
+ CambiaDolaresPesos()
+ } else {
+ CambiaPesosDolares()
+ }
+
+ }
+
+
+ // CAMBIO DOLARES-PESOS
+ function CambiaPesosDolares() {
+ debugger;
+ if ($("#LbImporteME").length) {
+
+ if ($("#TxtTipoCambio").length) {
+ $get('LbImporteME').value = '$ ' + FormatoNumero(ToDouble(ToDouble($get('TxtImporte').value) / ToDouble($get('TxtTipoCambio').value)), 2) + ' USD';
+ } else {
+ $get('LbImporteME').value = '';
+ }
+
+ }
+ }
+
+ function CambiaDolaresPesos() {
+ debugger;
+ if ($("#LbImporteMN").length) {
+
+ if ($("#TxtTipoCambio").length) {
+ $get('LbImporteMN').value = '$ ' + FormatoNumero(ToDouble(ToDouble($get('TxtImporte').value) * ToDouble($get('TxtTipoCambio').value)), 2) + ' MXN';
+ } else {
+ $get('LbImporteMN').value = ''
+ }
+
+ }
+ }
+
+ function AjustaTextboxDeudores() {
+
+ if (!(($("#C_RBLContado_2") && $("#C_RBLContado_2").is(':checked')) || ($("#C_RBLContado_3") && $("#C_RBLContado_3").is(':checked')) || ($("#C_RBLContado_4") && $("#C_RBLContado_4").is(':checked')))) {
+ return false;
+ }
+
+ var totalPoints = 0.00;
+ var TC = 1.00;
+
+ if ($get("TxtTipoCambio") && ToDouble($get("TxtTipoCambio").value) > 0) {
+ TC = ToDouble($get("TxtTipoCambio").value);
+ }
+
+ $('input[name*=TxtSaldoDeudor]').each(function () {
+ totalPoints += ToDouble($(this).val());
+
+ if ($("#LbImporteME").length) {
+ if ($("#TxtTipoCambio").length) {
+ $(this).parent().next().children('input[name*=TxtSaldoMonedaOriginal]').val(FormatoNumero(ToDouble($(this).val()) / TC, 2));
+
+ } else {
+ $(this).parent().next().children('input[name*=TxtSaldoMonedaOriginal]').val('0.00');
+ }
+ } else if ($("#LbImporteMN").length) {
+
+ if ($("#TxtTipoCambio").length) {
+ $(this).parent().next().children('input[name*=TxtSaldoMonedaOriginal]').val(FormatoNumero(ToDouble($(this).val()) * TC, 2));
+ } else {
+ $(this).parent().next().children('input[name*=TxtSaldoMonedaOriginal]').val('0.00');
+ }
+ }
+
+ });
+ $get('TxtImporte').value = FormatoNumero(totalPoints, 2);
+
+ var chkPesosBancos = $get("ChkPagarPesos");
+ var chkDolaresBancos = $get("ChkPagarDolares");
+
+ if (chkPesosBancos) {
+ CambiaPesosDolares()
+ } else if (chkDolaresBancos) {
+ CambiaDolaresPesos()
+ } else {
+ CambiaPesosDolares()
+ }
+ }
+
+ // ajuste Ingresos x comprobar y Deudores
+ function ClickDeudorChk(Chk, Obj, total, saldo) {
+
+ if ($("#" + Chk.id).is(":checked")) {
+ $('#' + Obj).val(saldo);
+ }else{
+ $('#' + Obj).val("");
+ }
+
+
+
+ /*
+ total = ToDouble(ToDouble(total).toFixed(2));
+ saldo = ToDouble(ToDouble(saldo).toFixed(2));
+ var totalTC = total;
+ var TC = 1.00;
+ if ($get("TxtTipoCambio") && ToDouble($get("TxtTipoCambio").value) > 0) {
+
+ TC = ToDouble($get("TxtTipoCambio").value);
+ total = total * TC;
+ }
+
+
+ if ($("#" + Chk.id).is(":checked")) {
+ $('#' + Obj).attr('disabled', false);
+ if (ToDouble($get('TxtImporte').value) != total) {
+
+ if ((ToDouble($get('TxtImporte').value) + saldo) > total) {
+ $('#' + Obj).val(saldo - (ToDouble($get('TxtImporte').value) + saldo - total));
+ $get('TxtImporte').value = (total / TC).toFixed(2)
+ }
+ else {
+ if (total > saldo) {
+ $('#' + Obj).val(saldo);
+ }
+
+ else {
+ $('#' + Obj).val(total);
+ }
+
+ if (ToDouble($get('TxtImporte').value) >= total) {
+
+ $('#' + Obj).val($get(total - 'TxtImporte').value);
+ $get('TxtImporte').value = (total / TC).toFixed(2)
+
+ } else {
+ $get('TxtImporte').value = (ToDouble($get('TxtImporte').value) + ToDouble($get(Obj).value) / TC).toFixed(2);
+ }
+ }
+
+ }
+ else {
+ $('#' + Obj).val(0);
+ }
+
+ }
+
+ else {
+ $('#' + Obj).attr('disabled', true);
+ if (ToDouble($get(Obj).value) > 0) {
+ $get('TxtImporte').value = ToDouble(ToDouble($get('TxtImporte').value) - ToDouble($get(Obj).value)).toFixed(2);
+ if ($get('TxtImporte').value < 0) {
+ $get('TxtImporte').value = 0
+ }
+ }
+ $('#' + Obj).val(0);
+ }
+
+ $('#' + Obj).val(ToDouble($get(Obj).value).toFixed(2));
+ CambioTipoMoneda();
+ */
+ }
+
+
+
diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb
index 150fa2d97..d1eb38b6a 100644
--- a/Compras/eFacturas.aspx.vb
+++ b/Compras/eFacturas.aspx.vb
@@ -25,6 +25,7 @@ Imports SharpCompress.Archive.Rar
Imports SharpCompress.Common
Imports SharpCompress.Reader
Imports Telerik.Web.UI
+Imports System.Data.SqlClient
'Imports Telerik.Web.UI
@@ -756,13 +757,24 @@ Partial Class Compras_eFacturas
End Set
End Property
+ Private Property CveMonedaFiltros As Integer
+ Get
+ If ViewState("CveMonedaFiltros") Is Nothing Then
+ ViewState("CveMonedaFiltros") = -1
+ End If
+ Return ViewState("CveMonedaFiltros").ToString.ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveMonedaFiltros") = value
+ End Set
+ End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
- 'EsGrupoDiaz = If(UsuarioActual.Empresa.Funcionalidad(382) = "1", True, False)
+ EsGrupoDiaz = If(UsuarioActual.Empresa.Funcionalidad(382) = "1", True, False)
ChecandoCorreo = False
@@ -816,12 +828,16 @@ Partial Class Compras_eFacturas
CargaPersonalViaticos()
CargaDdlRetIVA()
CargaDdlRetISR()
+ CargaDeudores()
End If
Dim LblSubProyectoTemp As New Label
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyectoTemp, "Seleccione")
LblSubProyecto.InnerText = $"{LblSubProyectoTemp.Text}:"
+
+ InicializaDTProrrateoGasolina()
+
End If
removeasincevent()
End Sub
@@ -1146,6 +1162,8 @@ Partial Class Compras_eFacturas
End If
End If
+ e.Row.FCCheckBox("chkRegistraFactura").Attributes.Add("onclick", "ChkRegsitraFacturas()")
+
End If
End Sub
Protected Sub GvDatos_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvD.RowUpdating
@@ -5176,6 +5194,23 @@ Partial Class Compras_eFacturas
End Property
+ Private Property DtDeudoresDetalle As DataTable
+ Get
+ Return CType(ViewState("DtDeudoresDetalle"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtDeudoresDetalle") = value
+ End Set
+ End Property
+
+ Private Property DtDeudores As DataTable
+ Get
+ Return CType(ViewState("DtDeudores"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DtDeudores") = value
+ End Set
+ End Property
Private Sub CargaClasificacionesComprobaciones()
@@ -5268,7 +5303,7 @@ Partial Class Compras_eFacturas
DivPersonalReembolso.Visible = False
DivCuentaCajaChicaReembolso.Visible = False
-
+ DivDeudores.Visible = False
Select Case RBLContado.SelectedValue
@@ -5280,6 +5315,10 @@ Partial Class Compras_eFacturas
DivCuentaCajaChicaReembolso.Visible = True
RfvTxtNumeroReembolso.Enabled = True
+ Case "4" ' Deudores
+ DivDeudores.Visible = True
+ RfvTxtNumeroReembolso.Enabled = False
+
End Select
UpRegistroFacturas.Update()
@@ -5314,8 +5353,64 @@ Partial Class Compras_eFacturas
DdlRetISRConcepto.Items.Insert(1, New ListItem("Resico", "3"))
End Sub
+ Protected Sub CargaDeudores(Optional CveMoneda As Integer = 1)
+ Dim Deudores As New ClsMovimientos
+ DdlDeudor.Items.Clear()
+ If Deudores.GetDeudoresSaldos2(-1, UsuarioActual.CveEmpresa) Then
+ DtDeudores = Deudores.DtResultados.FiltraParametros($"CveProveedor > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}")
+ DdlDeudor.DataSource = DtDeudores
+ DdlDeudor.DataBind()
+ DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1"))
+ UpDatos.Update()
+ CambieDeudor()
+ End If
+
+
+ Deudores.Dispose()
+ End Sub
+ Private Sub DdlDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDeudor.SelectedIndexChanged
+ CambieDeudor()
+ End Sub
+ Private Sub CambieDeudor()
+ Dim stringDeudor As String = DdlDeudor.SelectedItem.ToString
+ Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal
+
+ If DdlDeudor.SelectedValue.ToEntero > 0 Then
+ Dim Deudores As New ClsMovimientos
+ Dim OpcionSaldo As Integer = 1
+
+ If Deudores.GetDeudoresSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
+ DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0")
+ GvDeudores.DataSource = DtDeudoresDetalle.FiltraParametros("CveMoneda = 1")
+ GvDeudores.DataBind()
+ End If
+ Deudores.Dispose()
+ Else
+ GvDeudores.DataSource = Nothing
+ GvDeudores.DataBind()
+ End If
+
+ UpDeudores.Update()
+ End Sub
+
+ Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound
+ If e.Row.RowType = DataControlRowType.DataRow Then
+ Dim total As Decimal
+ Dim saldo As Decimal
+
+ saldo = e.Row.DataKey("Saldo").ToDecimal
+ total = 0D
+
+ e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
+ e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
+ e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
+
+ Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
+ End If
+ End Sub
+
Protected Sub DdlPersonal2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalReembolso.SelectedIndexChanged
ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue
If DdlPersonalReembolso.SelectedValue.ToEntero > 0 Then
@@ -5332,6 +5427,276 @@ Partial Class Compras_eFacturas
ViewState("CveCajaChica") = DdlCuentaCajaChicaReembolso.SelectedValue
End Sub
+#End Region
+
+
+
+#Region "PRORATEO"
+
+
+
+#Region "PRORRATEO GASOLINA"
+
+ Protected Sub LnlMostarProrateo_Click(sender As Object, e As EventArgs)
+
+ 'InicializaDTProrrateoGasolina()
+ CargarCentrosDeCosto(Nothing, Nothing, Nothing, LblSubProyectoProrrateoGasolina,)
+ GvProrrateoGasolina.Columns(0).HeaderText = LblSubProyectoProrrateoGasolina.Text
+ LblRiruloProrrareo.Text = $"Prorratear por { LblSubProyectoProrrateoGasolina.Text}"
+
+ DdlSubProyectoProrrateoGasolina.Items.Clear()
+ DdlSubProyectoProrrateoGasolina.DataSource = If(Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveProyecto:=-1))
+ DdlSubProyectoProrrateoGasolina.DataBind()
+ DdlSubProyectoProrrateoGasolina.Items.Insert(0, New ListItem("Todos", "-1"))
+
+ 'LblTotalProrrateoGasolina.Text = TxtTotal.Text
+
+ 'CargaProrratePS(-1)
+
+ RegistraScript("$('#DVModalProrrateoGasolina').modal();")
+ UpModalProrrateoGasolina.Update()
+ UpProrratearTitulo.Update()
+
+ 'DdlPS.txtText.Value = DdlPS.txtText.Value
+ 'DdlPS.txtValue.Value = DdlPS.txtValue.Value
+ 'UpRegistroFacturas.Update()
+
+ End Sub
+ Property DTProrrateoTmp As DataTable
+ Get
+ If ViewState("DTProrrateoTmp") Is Nothing Then
+ ViewState("DTProrrateoTmp") = New DataTable
+ End If
+ Return DirectCast(ViewState("DTProrrateoTmp"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DTProrrateoTmp") = value
+ End Set
+ End Property
+
+ Property DTProrrateo As DataTable
+ Get
+ If ViewState("DTProrrateo") Is Nothing Then
+ ViewState("DTProrrateo") = New DataTable
+ End If
+ Return DirectCast(ViewState("DTProrrateo"), DataTable)
+ End Get
+ Set(value As DataTable)
+ ViewState("DTProrrateo") = value
+ End Set
+ End Property
+
+ Property ProrratearFacturas As Boolean
+ Get
+ If ViewState("ProrratearFacturas") Is Nothing Then
+ ViewState("ProrratearFacturas") = False
+ End If
+ Return Boolean.Parse(ViewState("ProrratearFacturas").ToString)
+ End Get
+ Set(value As Boolean)
+ ViewState("ProrratearFacturas") = value
+ End Set
+ End Property
+
+ Private Sub InicializaDTProrrateoGasolina()
+
+ Dim TmpDTProrrateoGasolina As New DataTable
+ TmpDTProrrateoGasolina.Columns.Add("CvePS", GetType(Integer))
+ TmpDTProrrateoGasolina.Columns.Add("CveSubProyecto", GetType(Integer))
+ TmpDTProrrateoGasolina.Columns.Add("SubProyecto", GetType(String))
+ TmpDTProrrateoGasolina.Columns.Add("SubTotal", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("IVA", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("RetIVA", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("RetISR", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("Total", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("PorcentajeIVA", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("RetISRPorcentaje", GetType(Decimal))
+ TmpDTProrrateoGasolina.Columns.Add("RetIVAPorcentaje", GetType(Decimal))
+
+ TmpDTProrrateoGasolina.Columns.Add("CveUM", GetType(Integer))
+ TmpDTProrrateoGasolina.Columns.Add("CveClasificacion", GetType(Integer))
+ TmpDTProrrateoGasolina.Columns.Add("UM", GetType(String))
+ TmpDTProrrateoGasolina.Columns.Add("Clasificacion", GetType(String))
+ TmpDTProrrateoGasolina.Columns.Add("PS", GetType(String))
+ TmpDTProrrateoGasolina.Columns.Add("Porcentaje", GetType(Decimal))
+
+ DTProrrateoTmp = TmpDTProrrateoGasolina
+
+ End Sub
+
+ Protected Sub LnkProrrateoGasolina_Click(sender As Object, e As EventArgs)
+
+
+ CargarCentrosDeCosto(Nothing, Nothing, Nothing, LblSubProyectoProrrateoGasolina,)
+ GvProrrateoGasolina.Columns(0).HeaderText = LblSubProyectoProrrateoGasolina.Text
+ LblRiruloProrrareo.Text = $"Prorratear por { LblSubProyectoProrrateoGasolina.Text}"
+
+ DdlSubProyectoProrrateoGasolina.Items.Clear()
+ DdlSubProyectoProrrateoGasolina.DataSource = If(Not UsuarioActual.TienePermisoProceso(110), GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1), GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveProyecto:=-1))
+ DdlSubProyectoProrrateoGasolina.DataBind()
+ DdlSubProyectoProrrateoGasolina.Items.Insert(0, New ListItem("Todos", "-1"))
+
+ RegistraScript("$('#DVModalProrrateoGasolina').modal();")
+ UpModalProrrateoGasolina.Update()
+ UpProrratearTitulo.Update()
+
+ End Sub
+
+
+
+ Private Sub GvProrrateoGasolinaBind()
+ GvProrrateoGasolina.DataSource = DTProrrateoTmp
+ GvProrrateoGasolina.DataBind()
+ UpModalProrrateoGasolina.Update()
+ End Sub
+
+ Protected Sub LnkEliminarProrrateoGasolina_Click(sender As Object, e As EventArgs)
+
+ Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
+ DTProrrateoTmp.Rows.RemoveAt(GvRow.RowIndex)
+ DTProrrateoTmp.AcceptChanges()
+ ProrateoCalculaRestante()
+ GvProrrateoGasolinaBind()
+
+ End Sub
+
+
+
+ Protected Sub LnkAgregarProrrateoGasolina_Click(sender As Object, e As EventArgs)
+
+ Dim CvePs As Integer = DdlPS.SelectedValue.ToEntero
+
+ If Not CvePs > 0 Then
+ Alert("Debe seleccionar un producto", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim PsRow As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePs).FiltroPrimero("")
+
+ If PsRow Is Nothing Then
+ Alert("No se encontro el producto", TipoMensaje.MsgAdvertencia)
+ Exit Sub
+ End If
+
+ Dim CveUM As Integer = PsRow("CveUM").ToString.ToEntero
+ Dim UM As String = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("UnidadMedida", $" CveUnidadMedida = {CveUM} ")
+
+ Dim CveClasificacion As Integer = PsRow("CveClasificacion").ToString.ToEntero
+ Dim Clasificacion As String = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $" CveClasificacion = {CveClasificacion} ")
+
+
+ If DdlSubProyectoProrrateoGasolina.SelectedValue.ToEntero > 0 Then
+ AgregarProrrateoGasolina(DdlSubProyectoProrrateoGasolina.SelectedValue.ToEntero, DdlSubProyectoProrrateoGasolina.SelectedItem.Text, CvePs, CveUM, UM, CveClasificacion, Clasificacion)
+ Else
+ DTProrrateoTmp.Rows.Clear()
+
+ For Each item As ListItem In DdlSubProyectoProrrateoGasolina.Items
+ If item.Value.ToEntero > 0 Then
+ AgregarProrrateoGasolina(item.Value.ToEntero, item.Text, CvePs, CveUM, UM, CveClasificacion, Clasificacion)
+ End If
+ Next
+ End If
+
+ TxtPrecioProrrateoGasolina.Text = ""
+ DdlSubProyectoProrrateoGasolina.SelectedValueExist(-1)
+ UpModalProrrateoGasolina.Update()
+
+ End Sub
+
+
+ Private Sub AgregarProrrateoGasolina(CveSubProyecto As Integer, SubProyecto As String, CvePS As Integer, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String)
+
+ ''' este prco3eso compratira todo esto se debe de llevar a la genracion de la factura por porcentaje
+
+ Dim SubTotalOriginal As Decimal = 1
+ Dim IVAOriginal As Decimal = 0D 'TxtIVA.Text.ToDecimal
+ Dim RetISROriginal As Decimal = 0D 'TxtRetISR.Text.ToDecimal
+ Dim RetIVAOriginal As Decimal = 0D 'TxtRetIVA.Text.ToDecimal
+ Dim TotalOriginal As Decimal = 1
+
+ Dim totalParcialDeseado As Decimal = TxtPrecioProrrateoGasolina.Text.ToDecimal
+ Dim PorcentajeCalculado As Decimal = totalParcialDeseado / TotalOriginal
+
+ Dim subtotalParcial As Decimal = SubTotalOriginal * PorcentajeCalculado
+ Dim ivaParcial As Decimal = IVAOriginal * PorcentajeCalculado
+ Dim retIsrParcial As Decimal = RetISROriginal * PorcentajeCalculado
+ Dim retIvaParcial As Decimal = RetIVAOriginal * PorcentajeCalculado
+
+ Dim nRow As DataRow = DTProrrateoTmp.NewRow
+
+ nRow("CvePS") = DdlPS.SelectedValue.ToEntero
+ nRow("CveSubProyecto") = CveSubProyecto
+ nRow("SubProyecto") = SubProyecto
+
+ 'If CveFactura > 0 Then
+ nRow("IVA") = ivaParcial.RoundSQL(4)
+ nRow("RetIVA") = retIvaParcial.RoundSQL(4)
+ nRow("RetISR") = retIsrParcial.RoundSQL(4)
+ 'Else
+ 'nRow("IVA") = (ivaParcial / subtotalParcial).RoundSQL(4)
+ 'nRow("RetIVA") = (retIvaParcial / subtotalParcial).RoundSQL(4)
+ 'nRow("RetISR") = (retIsrParcial / subtotalParcial).RoundSQL(4)
+ 'End If
+
+ nRow("SubTotal") = subtotalParcial.RoundSQL(4)
+
+ nRow("Total") = totalParcialDeseado.RoundSQL(4)
+ nRow("PorcentajeIVA") = (ivaParcial / subtotalParcial).RoundSQL(4)
+ nRow("Porcentaje") = TxtPrecioProrrateoGasolina.Text.ToDecimal '((totalParcialDeseado.RoundSQL(4) * 100) / TotalOriginal).RoundSQL(2)
+
+ 'nRow("RetIVAPorcentaje") = (retIvaParcial / subtotalParcial).RoundSQL(4)
+ 'nRow("RetISRPorcentaje") = (retIsrParcial / subtotalParcial).RoundSQL(4)
+
+ nRow("CveUM") = CveUM
+ nRow("UM") = UM
+ nRow("CveClasificacion") = CveClasificacion
+ nRow("Clasificacion") = Clasificacion
+ nRow("PS") = DdlPS.txtText.Value
+
+ DTProrrateoTmp.Rows.Add(nRow)
+
+ ProrateoCalculaRestante()
+ GvProrrateoGasolinaBind()
+ End Sub
+
+
+ Function ProrateoCalculaRestante(Optional MostrarMensaje As Boolean = False) As Boolean
+ '''Esto no aplica por que es por factura
+
+ Dim Acumulado As Decimal = DTProrrateoTmp.SUM("Porcentaje").RoundSQL(2)
+ Dim Total As Decimal = 100 'TxtTotal.Text.ToDecimal.RoundSQL(2)
+ Dim Respuesta As Boolean = False
+
+ LblRestoProrrateoGasolina.Text = (Total - Acumulado).ToString("###,###,###.00")
+
+ If Acumulado = Total Then
+ Respuesta = True
+ Else
+ Respuesta = False
+ If MostrarMensaje Then
+
+ If Acumulado <> Total Then
+ Alert($"El porcentaje prorrateado es diferente de 100%, Diferencia: {(Acumulado - Total).Abs()}, Prorrateado:{Acumulado.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia)
+ End If
+
+ End If
+ End If
+
+ Return Respuesta
+
+ End Function
+
+ Protected Sub BtnGuardarProrrateoGasolina_Click(sender As Object, e As EventArgs)
+ If Not ProrateoCalculaRestante(True) Then
+ Exit Sub
+ End If
+ DTProrrateo = DTProrrateoTmp
+ RegistraScript("$('#DVModalProrrateoGasolina').modal('hide');")
+ End Sub
+
+
+#End Region
+
#End Region
Protected Sub LnkRegistarFactura_Click(sender As Object, e As EventArgs)
@@ -5353,9 +5718,52 @@ Partial Class Compras_eFacturas
Exit Sub
End If
+
+ If RBLContado.SelectedValue.ToEntero = 4 Then
+ If Not validaPagoDeudores() Then
+ Exit Sub
+ End If
+ End If
+
+ Dim Objcompras As New ClsCompras
+ Objcompras.IniciaTransacSQL()
+
+
+ Dim DTPagosDeudores As New DataTable
+
+ DTPagosDeudores.Columns.Add("CveIE", GetType(Decimal))
+ DTPagosDeudores.Columns.Add("Saldo", GetType(Decimal))
+ DTPagosDeudores.Columns.Add("RazonSocial", GetType(String))
+ DTPagosDeudores.Columns.Add("Folio", GetType(String))
+ DTPagosDeudores.Columns.Add("CveProveedor", GetType(Integer))
+ DTPagosDeudores.Columns.Add("SaldoVentas", GetType(Decimal))
+ DTPagosDeudores.Columns.Add("CveMoneda", GetType(Integer))
+ DTPagosDeudores.Columns.Add("TCPago", GetType(Decimal))
+ DTPagosDeudores.Columns.Add("ImportePago", GetType(Decimal))
+
+ For Each rw As GridViewRow In GvDeudores.Rows
+ If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then
+
+ Dim nRow As DataRow = DTPagosDeudores.NewRow
+ nRow("CveIE") = rw.DataKey("CveIE").ToEntero
+ nRow("CveMoneda") = rw.DataKey("CveMoneda").ToEntero
+ nRow("ImportePago") = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
+ nRow("TCPago") = rw.DataKey("TipoCambio").ToDecimal
+ nRow("CveProveedor") = DdlDeudor.SelectedValue.ToEntero
+ nRow("Saldo") = rw.DataKey("Saldo").ToDecimal
+
+ DTPagosDeudores.Rows.Add(nRow)
+
+ End If
+ Next
+
For Each GvRow As GridViewRow In GvD.Rows
+
If GvRow.FCCheckBox("chkRegistraFactura").Checked Then
+ Dim TotalFactura As Decimal = GvRow.DataKey("Total").ToDecimal
+ Dim SaldoFactura As Decimal = TotalFactura
+
Dim CFDIXmlPath As String = $"{UsuarioActual.Empresa.Ruta}Compras\{GvRow.DataKey("RFCDe")}\{GvRow.DataKey("XML")}"
If Not File.Exists(CFDIXmlPath) Then
ErrorProceso = True
@@ -5376,35 +5784,295 @@ Partial Class Compras_eFacturas
Dim CvePersonal As Integer = -1 'DdlPersonalReembolso.SelectedValue.ToEntero
Dim CveCajachica As Integer = -1 'DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero
- If RBLContado.SelectedValue.ToEntero = 6 Then
+ If RBLContado.SelectedValue.ToEntero = 6 Then 'Caja Chica
CveCajachica = DdlCuentaCajaChicaReembolso.SelectedValue.ToEntero
- Else
+ ElseIf RBLContado.SelectedValue.ToEntero = 2 Then ' viaticos
CvePersonal = DdlPersonalReembolso.SelectedValue.ToEntero
+ ElseIf RBLContado.SelectedValue.ToEntero = 4 Then ' deudores
+
End If
- CompraActual.ConfiguraRegistroRapidoReembolso(DdlPS.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, CveCajachica, CvePersonal,
- DdlRetIVAConcepto.SelectedValue.ToEntero, DdlRetISRConcepto.SelectedValue.ToEntero, NumeroReembolso:=TxtNumeroReembolso.Text)
- If CompraActual.AddCompra() Then
- Contador = Contador + 1
+
+
+ If CompraActual.ConfiguraRegistroCompra(DdlPS.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, CveCajachica, CvePersonal,
+ DdlRetIVAConcepto.SelectedValue.ToEntero, DdlRetISRConcepto.SelectedValue.ToEntero, NumeroReembolso:=TxtNumeroReembolso.Text,
+ DTProrrateo:=DTProrrateo, DTPagosDeudores:=DTPagosDeudores) Then
+ If CompraActual.AddCompra(Objcompras.IniciaTransacSQL()) Then
+ Contador = Contador + 1
+ Else
+ ErrorProceso = True
+ ErrorProcesoStr = CompraActual.MensajeError
+ Exit For
+ End If
Else
ErrorProceso = True
ErrorProcesoStr = CompraActual.MensajeError
Exit For
End If
+
+ If RBLContado.SelectedValue.ToEntero = 4 Then 'Deudores
+ Dim CompraActualPagar = New Compra
+ If Objcompras.GetCompras(CompraActual.CveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
+ If Objcompras.DtResultados IsNot Nothing AndAlso Objcompras.DtResultados.Rows.Count > 0 Then
+ Dim dr As DataRow = Objcompras.DtResultados.Rows(0)
+
+
+ CompraActualPagar.CveCompra = CompraActual.CveCompra
+ CompraActualPagar.CveTipoConceptoProveedor = dr("CveTipoConcepto").ToString.ToEntero
+ CompraActualPagar.CveProveedor = dr("CveProveedor").ToString.ToEntero
+ CompraActualPagar.CveMoneda = dr("CveMoneda").ToString.ToEntero
+ CompraActualPagar.Fecha = dr("Fecha").ToString.ToDate
+ CompraActualPagar.SerieFolio = dr("SerieFolio").ToString
+ 'CompraActualPagar.ProveedorNombre = TxtPagueseA.Text
+ CompraActualPagar.TC = dr("TipoCambio").ToString.ToDecimal
+ CompraActualPagar.Total = dr("Total").ToString.ToDecimal
+ CompraActualPagar.IVA = dr("IVA").ToString.ToDecimal
+ CompraActualPagar.IVADeducible = dr("IVADeducible").ToString.ToDecimal.RoundSQL
+ CompraActualPagar.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal.RoundSQL
+ CompraActualPagar.IEPS = dr("IEPS").ToString.ToDecimal
+ CompraActualPagar.RetIVA = dr("RetIVA").ToString.ToDecimal
+ CompraActualPagar.RetISR = dr("RetISR").ToString.ToDecimal
+ CompraActualPagar.CveConceptoRetIVA = dr("CveRetIVAConcepto").ToString.ToEntero
+ CompraActualPagar.CveConceptoRetISR = dr("CveRetISRConcepto").ToString.ToEntero
+ CompraActualPagar.PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
+ CompraActualPagar.UsuarioActual = UsuarioActual
+ CompraActualPagar.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
+ CompraActualPagar.EsImportacion = CBool(dr("EsImportacion"))
+ CompraActualPagar.CompraNoDeducible = dr("NoDeducible").ToString.ToEntero
+
+ ''Tipos de cambio
+ 'If Pago.CveMonedaPago = 1 AndAlso CompraActualPagar.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
+ ' Pago.TCCambioMoneda = 1 / TxtTipoCambio.Text.ToDecimal
+ 'ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActualPagar.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
+ ' Pago.TCPago = TxtTipoCambio.Text.ToDecimal
+ 'ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActualPagar.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
+ ' Pago.TCPago = TxtTipoCambio.Text.ToDecimal
+ ' Pago.TCCambioMoneda = TxtTipoCambio.Text.ToDecimal
+ 'End If
+
+ Else
+ ErrorProceso = True
+ End If
+ Else
+ ErrorProceso = True
+ End If
+
+
+ If Not ErrorProceso Then
+
+ Dim Pago As New CompraPago
+ Pago.Fecha = NowADS()
+ Pago.CveMonedaPago = 1
+
+
+ Dim ObjMov As New ClsContabilidad(Objcompras.IniciaTransacSQL())
+ Dim CvePlantillaPoliza As Integer = 2
+
+ Dim porAplicar As Decimal = DTPagosDeudores.SUM("ImportePago")
+
+ While (SaldoFactura > 0 Or porAplicar <= 0) And (ErrorProceso = False)
+
+
+ For Each dRow As DataRow In DTPagosDeudores.Rows
+
+ ' Dim SaldoDeudor As Decimal = dRow("Saldo").ToString.ToDecimal
+ Dim MaxPago As Decimal = dRow("ImportePago").ToString.ToDecimal
+ Dim ImportePagado As Decimal = 0D
+
+ If MaxPago > 0 Then
+
+ If MaxPago > SaldoFactura Then
+ ImportePagado = SaldoFactura
+ dRow("ImportePago") = (MaxPago - TotalFactura)
+ Else
+ ImportePagado = MaxPago
+ dRow("ImportePago") = 0
+ End If
+
+ Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Bancos/PopIECompras", CvePlantillaPoliza, ImportePagado, ImportePagado, Pago.CveMonedaPago, NowADS, "Registro factuta eFacturas", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=3)
+
+ Pago.CveIE = dRow("CveIE").ToString.ToEntero
+ Pago.CveMonedaPago = dRow("CveMoneda").ToString.ToEntero
+ Pago.ImportePago = ImportePagado
+ Pago.TCPago = 1
+ Pago.CveProveedor = DdlDeudor.SelectedValue.ToEntero
+ Pago.TipoPago = "DD"
+ If AplicaPrePolizaPagoCompra(CompraActualPagar, Pago, CvePrePoliza, ObjMov) Then
+ ErrorProceso = True
+ Exit For
+ End If
+
+ End If
+
+ SaldoFactura = (SaldoFactura - ImportePagado)
+
+ Next
+
+
+ porAplicar = DTPagosDeudores.SUM("ImportePago")
+
+ End While
+
+ End If
+
+ End If
+
+ End If
+ If ErrorProceso Then
+ Exit For
End If
Next
- If Not ErrorProceso Then
+ If ErrorProceso Then
+ Objcompras.RollBack()
+ Alert($"Se registraron {Contador} Compras. error {ErrorProcesoStr}", TipoMensaje.MsgAdvertencia)
+ Else
+ Objcompras.Commit()
+ CargaDatos(NowADS())
+ CambieDeudor()
CargaDatos(NowADS())
If Contador > 0 Then
Alert($"Se registraron {Contador} Compras")
End If
- Else
- Alert($"Se registraron {Contador} Compras. error {ErrorProcesoStr}", TipoMensaje.MsgAdvertencia)
End If
+ Objcompras.Dispose()
+
End Sub
+ Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs)
+ 'If ChkPagarPesos.Checked Then
+ ' DivTipoCambio.Visible = True
+ ' CargaCuentas()
+ ' CargaOtrosIngresos(1)
+ ' CargaDeudores(1)
+ ' CargaAcreedores(1)
+ ' CargaVentas(1)
+ ' CveMonedaFiltros = 1
+ ' TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
+ ' TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
+
+ ' GvIngresos.Columns(5).Visible = True
+ ' GvIngresos.Columns(6).Visible = True
+
+ ' GvDeudores.Columns(5).Visible = True
+ ' GvDeudores.Columns(6).Visible = True
+
+ ' 'RVImporte.Enabled = False
+ ' ' RVImporte.MaximumValue = "0.00"
+
+ ' CVImporteDolares.Enabled = True
+ 'Else
+ ' DivTipoCambio.Visible = False
+ ' CargaCuentas()
+ ' CargaOtrosIngresos(2)
+ ' CargaDeudores(2)
+ ' CargaAcreedores(2)
+ ' CargaVentas(2)
+ ' CveMonedaFiltros = 2
+ ' TxtFechaDocumento.Attributes.Remove("onchange")
+
+ ' GvIngresos.Columns(5).Visible = False
+ ' GvIngresos.Columns(6).Visible = False
+
+ ' GvDeudores.Columns(5).Visible = False
+ ' GvDeudores.Columns(6).Visible = False
+
+ ' 'RVImporte.Enabled = True
+ ' 'RVImporte.MaximumValue = LtlSaldo.Text.ToDecimal.ToString
+
+ ' CVImporteDolares.Enabled = False
+ ' CVImportePesos.Enabled = False
+ 'End If
+ 'UpDatos.Update()
+
+ 'RegistraScript("CambiaPesosDolares();")
+ End Sub
+
+ Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs)
+
+ 'If ChkPagarDolares.Checked Then
+ ' DivTipoCambio.Visible = True
+ ' CargaCuentas()
+ ' CargaOtrosIngresos(2)
+ ' CargaDeudores(2)
+ ' CargaAcreedores(2)
+ ' CargaVentas(2)
+ ' CveMonedaFiltros = 2
+ ' TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
+ ' TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
+
+ ' GvIngresos.Columns(5).Visible = True
+ ' GvIngresos.Columns(6).Visible = True
+
+ ' GvDeudores.Columns(5).Visible = True
+ ' GvDeudores.Columns(6).Visible = True
+
+ ' 'RVImporte.Enabled = False
+ ' 'RVImporte.MaximumValue = "0.00"
+
+ ' CVImportePesos.Enabled = True
+ 'Else
+ ' DivTipoCambio.Visible = False
+ ' CargaCuentas()
+ ' CargaOtrosIngresos(1)
+ ' CargaDeudores(1)
+ ' CargaAcreedores(1)
+ ' CargaVentas(1)
+ ' CveMonedaFiltros = 1
+ ' TxtFechaDocumento.Attributes.Remove("onchange")
+
+ ' GvIngresos.Columns(5).Visible = False
+ ' GvIngresos.Columns(6).Visible = False
+
+ ' GvDeudores.Columns(5).Visible = False
+ ' GvDeudores.Columns(6).Visible = False
+
+ ' ' RVImporte.Enabled = True
+ ' 'RVImporte.MaximumValue = LtlSaldo.Text.ToDecimal.ToString
+
+ ' CVImporteDolares.Enabled = False
+ ' CVImportePesos.Enabled = False
+ 'End If
+
+ 'UpDatos.Update()
+
+ 'RegistraScript("CambiaDolaresPesos();")
+
+ End Sub
+
+
+ Function validaPagoDeudores() As Boolean
+
+ Dim respuesta As Boolean = True
+
+ Dim totalFacturas As Decimal = 0D
+ Dim totalDeudores As Decimal = 0D
+
+ For Each gvRow As GridViewRow In GvDeudores.Rows
+ If gvRow.FCCheckBox("Chk").Checked Then
+ 'totalDeudores = totalDeudores + gvRow.DataKey("Saldo").ToDecimal
+ totalDeudores = totalDeudores + gvRow.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
+ End If
+ Next
+
+ For Each gvRow As GridViewRow In GvD.Rows
+ If gvRow.FCCheckBox("chkRegistraFactura").Checked Then
+ totalFacturas = totalFacturas + gvRow.DataKey("Total").ToDecimal
+ End If
+ Next
+
+ If totalFacturas > totalDeudores Then
+ respuesta = False
+ Alert("El importe de lasf acturas es superior al importe de deudores selecionado", TipoMensaje.MsgAdvertencia)
+ End If
+
+
+ Return respuesta
+
+ End Function
+
+
End Class
@@ -5630,6 +6298,7 @@ Public Class ClsCompraManager
Public Property CveCreditoDetalle As Integer = -1
Public Property CveIE As Integer = -1
Public Property CveCompraAmortizacion As Integer = -1
+ Public Property DTPagosDeudores As DataTable
Public Sub New(XmlFuente As String, OpcionCarga As EnumCargaCompra, DTTiposGastos As DataTable, UsuarioActual As Usuario)
@@ -5940,7 +6609,7 @@ Public Class ClsCompraManager
#End Region
End Sub
- Public Function ConfiguraRegistroRapidoReembolso(CvePS As Integer, CveSubProyecto As Integer, CveCajaChica As Integer, CvePersonal As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer, NumeroReembolso As String) As Boolean
+ Public Function ConfiguraRegistroCompra(CvePS As Integer, CveSubProyecto As Integer, CveCajaChica As Integer, CvePersonal As Integer, CveRetIVAConcepto As Integer, CveRetISRConcepto As Integer, NumeroReembolso As String, DTProrrateo As DataTable, DTPagosDeudores As DataTable) As Boolean
Dim respuesta As Boolean = True
Me.CveSubProyecto = CveSubProyecto
@@ -5951,6 +6620,7 @@ Public Class ClsCompraManager
Me.CveRetISRConcepto = CveRetISRConcepto
Me.CveTipoPoliza = 3
Me.NumeroReembolso = NumeroReembolso
+ Me.DTPagosDeudores = DTPagosDeudores
Dim dRowSubProyecto As DataRow = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, CveSubProyecto:=CveSubProyecto).FiltroPrimero("")
@@ -5983,10 +6653,100 @@ Public Class ClsCompraManager
respuesta = False
End If
+
+ respuesta = Prorratear(DTProrrateo)
+
Return respuesta
End Function
+ Function Prorratear(DtProrrateo As DataTable) As Boolean
+
+ Dim Respuesta As Boolean = True
+
+ If DtProrrateo.Rows.Count > 0 Then
+
+ Dim DT_Impuestos As DataTable = TmpDT.FiltraParametros("", "", {"IVAPorcentaje", "RetIVAPorcentaje", "RetISRPorcentaje"})
+ Dim TmpDTCopy As DataTable = TmpDT.Copy
+
+ TmpDT.Rows.Clear()
+
+ Dim SubTotalOriginal As Decimal = SubTotal
+ Dim IVAOriginal As Decimal = IVA
+ Dim RetISROriginal As Decimal = RetISR
+ Dim RetIVAOriginal As Decimal = RetIVA
+ Dim TotalOriginal As Decimal = Total
+ Dim DescuentoOriginal As Decimal = Descuento
+
+
+ For Each dRowImp As DataRow In DT_Impuestos.Rows
+
+ Dim impPorcentajeIVA As Decimal = dRowImp("IVAPorcentaje").ToString.ToDecimal
+ Dim impRetIVAPorcentaje As Decimal = dRowImp("RetIVAPorcentaje").ToString.ToDecimal
+ Dim impRetISRPorcentaje As Decimal = dRowImp("RetISRPorcentaje").ToString.ToDecimal
+
+ Dim ImpSubTotal As Decimal = TmpDTCopy.SUM("Total", $" (IVAPorcentaje = {impPorcentajeIVA} OR IVAPorcentaje IS NULL ) AND (RetIVAPorcentaje = {impRetIVAPorcentaje} OR RetIVAPorcentaje IS NULL) AND (RetISRPorcentaje = {impRetISRPorcentaje} OR RetISRPorcentaje IS NULL)")
+ Dim ImpIVA As Decimal = TmpDTCopy.SUM("IVA", $" (IVAPorcentaje = {impPorcentajeIVA} OR IVAPorcentaje IS NULL ) AND (RetIVAPorcentaje = {impRetIVAPorcentaje} OR RetIVAPorcentaje IS NULL) AND (RetISRPorcentaje = {impRetISRPorcentaje} OR RetISRPorcentaje IS NULL)")
+
+ Dim impTotal As Decimal = (ImpSubTotal + ImpIVA)
+
+ For Each dRow As DataRow In DtProrrateo.Rows
+
+
+ Dim totalParcialDeseado As Decimal = (dRow("Porcentaje").ToString.ToDecimal / 100D) * impTotal
+ Dim PorcentajeCalculado As Decimal = totalParcialDeseado / impTotal
+
+ Dim subtotalParcial As Decimal = ImpSubTotal * PorcentajeCalculado
+ Dim ivaParcial As Decimal = ImpIVA * PorcentajeCalculado
+ Dim retIsrParcial As Decimal = impRetISRPorcentaje * PorcentajeCalculado
+ Dim retIvaParcial As Decimal = impRetIVAPorcentaje * PorcentajeCalculado
+
+ Dim nIVA As Decimal = ivaParcial.RoundSQL(6)
+ Dim nRetIVA As Decimal = retIvaParcial.RoundSQL(6)
+ Dim nRetISR As Decimal = retIsrParcial.RoundSQL(6)
+ Dim nSubTotal As Decimal = subtotalParcial.RoundSQL(6)
+ Dim nTotal As Decimal = totalParcialDeseado.RoundSQL(6)
+ Dim nPorcentajeIVA As Decimal = impPorcentajeIVA '(ivaParcial / subtotalParcial).RoundSQL(4)
+ Dim nPorcentaje As Decimal = ((totalParcialDeseado.RoundSQL(4) * 100) / impTotal).RoundSQL(4)
+ Dim nRetIVAPorcentaje As Decimal = (retIvaParcial / subtotalParcial).RoundSQL(4)
+ Dim nRetISRPorcentaje As Decimal = (retIsrParcial / subtotalParcial).RoundSQL(4)
+
+
+ AddPS(1, dRow("CveUM").ToString.ToEntero, dRow("UM").ToString, dRow("CveClasificacion").ToString.ToEntero, dRow("Clasificacion").ToString, dRow("CvePS").ToString.ToEntero, dRow("PS").ToString, 1, dRow("CveSubProyecto").ToString, dRow("SubProyecto").ToString, "",
+ "-1", "", nSubTotal, nTotal, nIVA, nRetIVA, nRetISR, 0, 0, 0, PorcentajeIVA:=nPorcentajeIVA,
+ CargaXml:=True, PorcentajeRetIVA:=nRetIVAPorcentaje, PorcentajeRetISR:=nRetISRPorcentaje)
+
+ Next
+
+
+ Next
+
+
+
+ Dim SubTotalDetalle As Decimal = TmpDT.SUM("Total")
+ Dim IVADetalle As Decimal = TmpDT.SUM("IVA")
+ Dim RetIVADetalle As Decimal = TmpDT.SUM("RetIVA")
+ Dim RetISRDetalle As Decimal = TmpDT.SUM("RetISR")
+ Dim DescuentoDetalle As Decimal = TmpDT.SUM("Descuento")
+
+ Dim Diferencia As Decimal = (TotalOriginal - (SubTotalDetalle + IVADetalle - RetIVADetalle - RetISRDetalle - DescuentoDetalle)).RoundSQL
+
+ If Math.Abs(Diferencia) > 0.01 Then
+ Respuesta = False
+ Else
+ Total = Total.RoundSQL
+ SubTotal = SubTotal.RoundSQL
+ IVA = IVA.RoundSQL
+ RetISR = RetISR.RoundSQL
+ RetIVA = RetIVA.RoundSQL
+ End If
+
+ End If
+
+ Return Respuesta
+
+ End Function
+
Private Function AjustesValidacion() As Boolean
Dim respuesta As Boolean = True
'VALIDA IMPORTES
@@ -7055,12 +7815,13 @@ Public Class ClsCompraManager
End If
End Function
- Public Function AddCompra() As Boolean
+ Public Function AddCompra(ByRef transaccion As SqlTransaction) As Boolean
If Not AjustesValidacion() Then Return False
Dim respuesta As Boolean = True
- Dim ObjCompras As New ClsCompras
+
+ Dim ObjCompras As New ClsCompras(transaccion)
Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
If Not AddPrepolizaCabecera(ObjConta) Then
@@ -7122,14 +7883,15 @@ Public Class ClsCompraManager
If Not ObjCompras.UpdateCompraFactura(Me.CveCompra, Me.CveFactura, Me.Serie, Me.Folio) Then respuesta = False
End If
- If respuesta Then
- ObjCompras.Commit()
- Else
- ObjCompras.RollBack()
- End If
- ObjCompras.Dispose()
- ObjConta.Dispose()
+ 'If respuesta Then
+ ' ObjCompras.Commit()
+ 'Else
+ ' ObjCompras.RollBack()
+ 'End If
+
+ 'ObjCompras.Dispose()
+ 'ObjConta.Dispose()
Return respuesta
End Function