Ejemplo n.º 1
0
        public static void UpdateWithValidation(tsa_ComprobantesDataset.tsa_ComprobantesRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            if (RowIsValid(row))
            {
                Update(row);
            }
        }
Ejemplo n.º 2
0
        public static void Update(tsa_ComprobantesDataset.tsa_ComprobantesRow row)
        {
            if (row.RowState == DataRowState.Detached)
            {
                ((tsa_ComprobantesDataset.tsa_ComprobantesDataTable)row.Table).Addtsa_ComprobantesRow(row);
            }

            Update(row.Table);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Obtiene un registro de la tabla tsa_Comprobantes que luego puede ser persistido en la base de datos.
 /// </summary>
 public static tsa_ComprobantesDataset.tsa_ComprobantesRow GetByPk(string IdComprobante)
 {
     tsa_ComprobantesDataset.tsa_ComprobantesRow row = mz.erp.dataaccess.tsa_Comprobantes.GetByPk(IdComprobante);
     if (row != null)
     {
         foreach (DataColumn dc in row.Table.Columns)
         {
             if (row[dc] == System.DBNull.Value)
             {
                 row[dc] = Util.DefaultValue(dc.DataType);
             }
         }
     }
     return(row);
 }
Ejemplo n.º 4
0
        private void CommitComprobante()
        {
            tsa_ComprobantesDataset.tsa_ComprobantesRow row = ((tsa_ComprobantesDataset)_dataComprobantes).tsa_Comprobantes.Newtsa_ComprobantesRow();

            DateTime now   = mz.erp.businessrules.Sistema.DateTime.Now;
            DateTime fc    = this.FechaComprobante;
            DateTime fecha = new DateTime(fc.Year, fc.Month, fc.Day, now.Hour, now.Minute, now.Second);

            row.Fecha         = fecha;
            row.FechaCreacion = mz.erp.businessrules.Sistema.DateTime.Now;
            row.IdComprobante = this.IdComprobante;
            row.IdCuenta      = this._cuenta.IdCuenta;
            row.IdResponsable = this._IdResponsable;

            row.IdTipoDeComprobante = this.TipoComprobanteDestino;
            //row.Numero = "";//Util.NewStringId();
            row.IdCotizacionCierre = ComprobantesRules.Contabilidad_CotizacionReferencia;
            row.Total = this.Total;
            row.IdCondicionDeVenta = "1";

            row.IdConexionCreacion           = Security.IdConexion;
            row.IdConexionUltimaModificacion = Security.IdConexion;

            row.IdEmpresa  = Security.IdEmpresa;
            row.IdSucursal = Security.IdSucursal;

            row.IdInstanciaCaja = string.Empty;
            row.IdMonedaCierre  = ComprobantesRules.Contabilidad_MonedaReferencia;
            row.IdReservado     = 0;

            //this.Numero = row.Numero;
            row.Numero = this.Numero;             //ORL. Le paso al row el valor de comprobante.Numero para que no reviente en los items si es nulo.

            //cargo los datos adicionles del cliente
            row.Cliente       = this._cuenta.Nombre;
            row.Domicilio     = this._cuenta.Domicilio;
            row.TipoDocumento = this._cuenta.TipoDocumento;
            row.Documento     = this._cuenta.Documento;
            row.Observaciones = this._observaciones;            //this.InfoObservaciones;
            row.Aux1          = string.Empty;
            row.Aux1          = string.Empty;
            row.Aux1          = string.Empty;

            ((tsa_ComprobantesDataset)_dataComprobantes).tsa_Comprobantes.Addtsa_ComprobantesRow(row);
        }
        public void Commit()
        {
            _dataComprobante = new tsa_ComprobantesExDataset();

            foreach (string _idComprobanteAAnular in _idComprobantesAAnular)
            {
                if (_idComprobanteAAnular != null && _idComprobanteAAnular != string.Empty)
                {
                    tsa_ComprobantesDataset.tsa_ComprobantesRow rowAux = businessrules.tsa_Comprobantes.GetByPk(_idComprobanteAAnular);
                    if (rowAux != null)
                    {
                        string IdTipoDeComprobante = rowAux.IdTipoDeComprobante;
                        if (_tableComprobantesAnulacion.ContainsKey(IdTipoDeComprobante))
                        {
                            string IdTipoDeComprobanteAnula = Convert.ToString(_tableComprobantesAnulacion[IdTipoDeComprobante]);
                            tsa_ComprobantesDataset.tsa_ComprobantesRow rowC = mz.erp.businessrules.tsa_Comprobantes.GetByPk(_idComprobanteAAnular);
                            rowC.IdTipoDeComprobante = IdTipoDeComprobanteAnula;
                            _dataComprobante.tsa_Comprobantes.ImportRow((DataRow)rowC);
                            tsa_ComprobantesDetDataset dataCD = mz.erp.businessrules.tsa_ComprobantesDet.GetByPk(_idComprobanteAAnular);
                            foreach (DataRow row in dataCD.tsa_ComprobantesDet.Rows)
                            {
                                if (row != null)
                                {
                                    row["IdTipoDeComprobante"] = IdTipoDeComprobanteAnula;
                                    _dataComprobante.tsa_ComprobantesDet.ImportRow(row);
                                }
                            }


                            tsa_ComprobanteDetalleImpuestosDataset dataCDI = mz.erp.businessrules.tsa_ComprobanteDetalleImpuestos.GetList(_idComprobanteAAnular);
                            foreach (DataRow row in dataCDI.tsa_ComprobanteDetalleImpuestos.Rows)
                            {
                                if (row != null)
                                {
                                    row["IdTipoDeComprobante"] = IdTipoDeComprobanteAnula;
                                    _dataComprobante.tsa_ComprobanteDetalleImpuestos.ImportRow(row);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Valida un tsa_ComprobantesRow.
        /// </summary>
        public static bool RowIsValid(tsa_ComprobantesDataset.tsa_ComprobantesRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);
            bool   isValid = true;
            string mensaje;


            if (!IdComprobanteIsValid(row.IdComprobante, out mensaje))
            {
                row.SetColumnError("IdComprobante", mensaje);
                isValid = false;
            }

            if (!IdEmpresaIsValid(row.IdEmpresa, out mensaje))
            {
                row.SetColumnError("IdEmpresa", mensaje);
                isValid = false;
            }

            if (!IdSucursalIsValid(row.IdSucursal, out mensaje))
            {
                row.SetColumnError("IdSucursal", mensaje);
                isValid = false;
            }

            if (!IdInstanciaCajaIsValid(row.IdInstanciaCaja, out mensaje))
            {
                row.SetColumnError("IdInstanciaCaja", mensaje);
                isValid = false;
            }

            if (!IdTipoDeComprobanteIsValid(row.IdTipoDeComprobante, out mensaje))
            {
                row.SetColumnError("IdTipoDeComprobante", mensaje);
                isValid = false;
            }

            if (!NumeroIsValid(row.Numero, out mensaje))
            {
                row.SetColumnError("Numero", mensaje);
                isValid = false;
            }

            if (!FechaIsValid(row.Fecha, out mensaje))
            {
                row.SetColumnError("Fecha", mensaje);
                isValid = false;
            }

            if (!IdCuentaIsValid(row.IdCuenta, out mensaje))
            {
                row.SetColumnError("IdCuenta", mensaje);
                isValid = false;
            }

            if (!IdResponsableIsValid(row.IdResponsable, out mensaje))
            {
                row.SetColumnError("IdResponsable", mensaje);
                isValid = false;
            }

            if (!TotalIsValid(row.Total, out mensaje))
            {
                row.SetColumnError("Total", mensaje);
                isValid = false;
            }


            if (!IdMonedaCierreIsValid(row.IdMonedaCierre, out mensaje))
            {
                row.SetColumnError("IdMonedaCierre", mensaje);
                isValid = false;
            }

            if (!IdCotizacionCierreIsValid(row.IdCotizacionCierre, out mensaje))
            {
                row.SetColumnError("IdCotizacionCierre", mensaje);
                isValid = false;
            }

            if (!FechaCreacionIsValid(row.FechaCreacion, out mensaje))
            {
                row.SetColumnError("FechaCreacion", mensaje);
                isValid = false;
            }

            if (!IdConexionCreacionIsValid(row.IdConexionCreacion, out mensaje))
            {
                row.SetColumnError("IdConexionCreacion", mensaje);
                isValid = false;
            }

            if (!UltimaModificacionIsValid(row.UltimaModificacion, out mensaje))
            {
                row.SetColumnError("UltimaModificacion", mensaje);
                isValid = false;
            }

            if (!IdConexionUltimaModificacionIsValid(row.IdConexionUltimaModificacion, out mensaje))
            {
                row.SetColumnError("IdConexionUltimaModificacion", mensaje);
                isValid = false;
            }

            if (!IdReservadoIsValid(row.IdReservado, out mensaje))
            {
                row.SetColumnError("IdReservado", mensaje);
                isValid = false;
            }

            if (!RowIdIsValid(row.RowId, out mensaje))
            {
                row.SetColumnError("RowId", mensaje);
                isValid = false;
            }
            ;

            return(isValid);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Envia los cambios del tsa_ComprobantesRow a la base de datos.
        /// </summary>
        public static void Update(tsa_ComprobantesDataset.tsa_ComprobantesRow row)
        {
            ApplicationAssert.Check(row != null, "El argumento row no debe ser nulo.", ApplicationAssert.LineNumber);

            mz.erp.dataaccess.tsa_Comprobantes.Update(row);
        }
Ejemplo n.º 8
0
        public static void PrintReportComprobantes(string IdComprobante, string idTipoDecomprobante, Form parent)
        {
            string  family      = string.Empty;
            DataRow rowTipoComp = mz.erp.businessrules.tsy_TiposDeComprobantes.GetByPk(idTipoDecomprobante);

            if (rowTipoComp != null)
            {
                family = Convert.ToString(rowTipoComp["Familia"]);
                bool      impresionHabilitada = Variables.GetValueBool("Comprobantes." + family + ".ImpresionManualHabilitada");
                ArrayList tiposcomp           = mz.erp.systemframework.Util.Parse(Variables.GetValueString("Reportes.TiposDeComprobantes." + family), ",");
                if (impresionHabilitada)
                {
                    if (tiposcomp.Contains(idTipoDecomprobante))
                    {
                        /* Silvina 20110223 - Tarea 36 */

                        ArrayList compPagos = mz.erp.systemframework.Util.Parse(Variables.GetValueString("Comprobantes.ComprobantesDePago"), ",");
                        if (compPagos.Contains(idTipoDecomprobante))
                        {
                            FrmPreviewReport          preview2 = new FrmPreviewReport();
                            ReportParameterCollection datos    = new ReportParameterCollection();
                            tsa_ComprobantesDataset.tsa_ComprobantesRow comp = mz.erp.businessrules.tsa_Comprobantes.GetByPk(IdComprobante);
                            decimal   Total = comp.Total;
                            DataTable table = mz.erp.businessrules.tsa_Comprobantes.GetComprobanteDePagoView(IdComprobante);

                            string moneda = mz.erp.businessrules.tfi_Monedas.GetDescripcionMoneda(comp.IdMonedaCierre);

                            string textoNumeros = NumberToText.NumberToWords(Total, moneda);

                            string nombreEmpresa = Variables.GetValueString("Sistema.NombreEmpresa");
                            table = AddColumn.AddColumnToTable(table, "NombreEmpresa", nombreEmpresa);
                            string domicilioEmpresa = Variables.GetValueString("Sistema.DireccionEmpresa");
                            table = AddColumn.AddColumnToTable(table, "DomicilioEmpresa", domicilioEmpresa);
                            string cuitEmpresa = Variables.GetValueString("Sistema.CUITEmpresa");
                            table = AddColumn.AddColumnToTable(table, "CUITEmpresa", cuitEmpresa);

                            foreach (DataRow row in table.Rows)
                            {
                                row["TextoTotal"] = textoNumeros;
                            }

                            preview2.ShowReport(table, "ReportComprobantes" + family + ".RPX", parent, datos);
                        }
                        else
                        {
                            /* Fin Silvina */

                            FrmPreviewReport          preview2 = new FrmPreviewReport();
                            ReportParameterCollection datos    = new ReportParameterCollection();
                            datos.Add(new ReportParameter("DireccionEmpresa", Variables.GetValueString("Sistema.DireccionEmpresa")));
                            datos.Add(new ReportParameter("CategoriaIvaEmpresa", Variables.GetValueString("Sistema.CategoriaDeIvaEmpresa")));
                            datos.Add(new ReportParameter("TelefonoEmpresa", Variables.GetValueString("Sistema.TelefonosEmpresa")));
                            datos.Add(new ReportParameter("CUITEmpresa", Variables.GetValueString("Sistema.CUITEmpresa")));
                            datos.Add(new ReportParameter("IngresosBrutosEmpresa", Variables.GetValueString("Sistema.IngresosBrutosEmpresa")));
                            datos.Add(new ReportParameter("InicioActividadesEmpresa", Variables.GetValueString("Sistema.InicioActividadesEmpresa")));
                            datos.Add(new ReportParameter("Logo", Variables.GetValueString("Reportes.Logo")));
                            datos.Add(new ReportParameter("Etiqueta1", Variables.GetValueString("Cuentas.CampoAuxiliar1.Etiqueta")));
                            datos.Add(new ReportParameter("Etiqueta2", Variables.GetValueString("Cuentas.CampoAuxiliar2.Etiqueta")));
                            datos.Add(new ReportParameter("Etiqueta3", Variables.GetValueString("Cuentas.CampoAuxiliar3.Etiqueta")));

                            string IdVariablesAuxiliares = Variables.GetValueString("Reportes.Comprobantes." + family + ".VariablesAuxiliares");
                            //los id de variables
                            ArrayList ids = mz.erp.systemframework.Util.Parse(IdVariablesAuxiliares, ",");

                            VariablesAuxiliares varAuxs = new VariablesAuxiliares(IdComprobante, idTipoDecomprobante);

                            foreach (VariableAuxiliar var in varAuxs.VariablesDeUsuario)
                            {
                                if (ids.Contains(var.Id))
                                {
                                    string valor = var.Descripcion + ": " + var.Valor;
                                    datos.Add(new ReportParameter("Param" + var.Id, valor));
                                }
                            }
                            DataTable table = mz.erp.businessrules.reportes.StatementSQLFactory.GetSQLForComprobantesReport(IdComprobante, family);
                            preview2.ShowReport(table, "ReportComprobantes" + family + ".RPX", parent, datos);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(parent, "No esta habilitada la impresion para este tipo de comprobante", "Informacion", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                }
            }
        }
        public override void Commit()
        {
            base.Commit();
            tsa_ComprobantesDataset.tsa_ComprobantesRow row = mz.erp.businessrules.tsa_Comprobantes.GetByPk(IdComprobante);
            //Agrego el comprobante anulado a la tabla de tsa_Comprobantes para evitar problemas de Foreign key
            _dataComprobante.tsa_Comprobantes.ImportRow(row);
            string IdTipoComprobante = row.IdTipoDeComprobante;

            //Creo el nuevo comprobante de Anulacion que es similar al comprobante anulado
            tsa_ComprobantesExDataset.tsa_ComprobantesRow rowComprobante = _dataComprobante.tsa_Comprobantes.Newtsa_ComprobantesRow();
            rowComprobante.IdComprobante       = mz.erp.systemframework.Util.NewStringId();
            rowComprobante.Numero              = row.Numero;
            rowComprobante.IdTipoDeComprobante = Variables.GetValueString("Momentos.Anular.Comprobantes." + IdTipoComprobante);
            rowComprobante.IdInstanciaCaja     = row.IdInstanciaCaja;
            rowComprobante.IdCuenta            = row.IdCuenta;
            rowComprobante.IdResponsable       = row.IdResponsable;
            rowComprobante.Total              = row.Total;
            rowComprobante.IdMonedaCierre     = row.IdMonedaCierre;
            rowComprobante.IdCotizacionCierre = row.IdCotizacionCierre;
            rowComprobante.FechaCreacion      = mz.erp.businessrules.Sistema.DateTime.Now;
            rowComprobante.IdConexionCreacion = Security.IdConexion;
            //rowComprobante.UltimaModificacion = null;
            rowComprobante.IdConexionUltimaModificacion = Security.IdConexion;
            rowComprobante.IdReservado = 0;
            rowComprobante.RowId       = Guid.Empty;
            rowComprobante.IdEmpresa   = Security.IdEmpresa;
            rowComprobante.IdSucursal  = Security.IdSucursal;

            _dataComprobante.tsa_Comprobantes.Addtsa_ComprobantesRow(rowComprobante);



            //Recupera los valores relacionados con el comprobante de pago a anular
            tsa_ComprobanteDetalleDePagosDataset dataDetalleDePagos = mz.erp.businessrules.tsa_ComprobanteDetalleDePagos.GetList(null, null, this.IdComprobante, null, decimal.MinValue);

            foreach (tsa_ComprobanteDetalleDePagosDataset.tsa_ComprobanteDetalleDePagosRow rowDetalleDePagos in dataDetalleDePagos.tsa_ComprobanteDetalleDePagos.Rows)
            {
                _dataComprobante.tfi_Valores.LoadDataRow(mz.erp.businessrules.tfi_Valores.GetByPk(rowDetalleDePagos.IdValor).ItemArray, true);
                tsa_ComprobantesExDataset.tsa_ComprobanteDetalleDePagosRow rowDP = _dataComprobante.tsa_ComprobanteDetalleDePagos.Newtsa_ComprobanteDetalleDePagosRow();
                rowDP.IdComprobante       = rowComprobante.IdComprobante;
                rowDP.IdValor             = rowDetalleDePagos.IdValor;
                rowDP.IdTipoDeComprobante = rowComprobante.IdTipoDeComprobante;
                rowDP.Numero             = rowComprobante.Numero;
                rowDP.Monto              = rowComprobante.Total;
                rowDP.IdMoneda           = rowComprobante.IdMonedaCierre;
                rowDP.IdCotizaicon       = rowComprobante.IdCotizacionCierre;
                rowDP.FechaCreacion      = mz.erp.businessrules.Sistema.DateTime.Now;
                rowDP.IdConexionCreacion = Security.IdConexion;
                //rowDP.UltimaModificacion = null;
                rowDP.IdConexionUltimaModificacion = Security.IdConexion;
                rowDP.IdReservado = 0;
                rowDP.RowId       = Guid.Empty;
                rowDP.IdSucursal  = Security.IdSucursal;
                rowDP.IdEmpresa   = Security.IdEmpresa;
                _dataComprobante.tsa_ComprobanteDetalleDePagos.Addtsa_ComprobanteDetalleDePagosRow(rowDP);
            }

            //Recuperar de detalle de deuda las filas relacionadas con el comprobante a anular
            tsa_ComprobanteDetalleDeudaDataset dataDetalleDeuda = mz.erp.businessrules.tsa_ComprobanteDetalleDeuda.GetList(row.IdComprobante, row.IdTipoDeComprobante, row.Numero);



            //Crear una nueva fila en detalle de deuda para el comprobante de anulacion
            int signo = Convert.ToInt32(mz.erp.businessrules.tsy_TiposDeComprobantes.GetByPk(rowComprobante.IdTipoDeComprobante).signo);

            tsa_ComprobantesExDataset.tsa_ComprobanteDetalleDeudaRow rowDetalleDeuda = _dataComprobante.tsa_ComprobanteDetalleDeuda.Newtsa_ComprobanteDetalleDeudaRow();
            rowDetalleDeuda.IdComprobante       = rowComprobante.IdComprobante;
            rowDetalleDeuda.Cuota               = 1;
            rowDetalleDeuda.IdTipoDeComprobante = rowComprobante.IdTipoDeComprobante;
            rowDetalleDeuda.Numero              = rowComprobante.Numero;
            rowDetalleDeuda.FechaEmision        = mz.erp.businessrules.Sistema.DateTime.Now;
            rowDetalleDeuda.FechaVencimiento    = mz.erp.businessrules.Sistema.DateTime.Now;
            rowDetalleDeuda.Importe             = rowComprobante.Total * signo;
            rowDetalleDeuda.Saldo               = 0;
            rowDetalleDeuda.IdMonedaCierre      = string.Empty;
            rowDetalleDeuda.IdCotizacionCierre  = string.Empty;
            rowDetalleDeuda.FechaCreacion       = mz.erp.businessrules.Sistema.DateTime.Now;
            rowDetalleDeuda.IdConexionCreacion  = Security.IdConexion;
            //rowDetalleDeuda.UltimaModificacion = null;
            rowDetalleDeuda.IdConexionUltimaModificacion = Security.IdConexion;
            rowDetalleDeuda.IdReservado = 0;
            rowDetalleDeuda.RowId       = Guid.Empty;
            rowDetalleDeuda.IdSucursal  = Security.IdSucursal;
            rowDetalleDeuda.IdEmpresa   = Security.IdEmpresa;

            _dataComprobante.tsa_ComprobanteDetalleDeuda.Addtsa_ComprobanteDetalleDeudaRow(rowDetalleDeuda);

            //Asociar en tsa_AplicaciondePagos el comprobante anulado con el comprobante que lo anula
            //el comprobante de pago anulado va como destino y el comrpobante que anula va como origen
            foreach (tsa_ComprobanteDetalleDeudaDataset.tsa_ComprobanteDetalleDeudaRow rowDD in dataDetalleDeuda.tsa_ComprobanteDetalleDeuda.Rows)
            {
                tsa_ComprobantesExDataset.tsa_AplicacionPagosRow rowAplicacionPago = _dataComprobante.tsa_AplicacionPagos.Newtsa_AplicacionPagosRow();
                rowAplicacionPago.IdComprobanteOrigen     = rowDetalleDeuda.IdComprobante;
                rowAplicacionPago.CuotaOrigen             = rowDetalleDeuda.Cuota;
                rowAplicacionPago.IdComprobanteDestino    = rowDD.IdComprobante;
                rowAplicacionPago.IdTipoComprobanteOrigen = rowDetalleDeuda.IdTipoDeComprobante;
                rowAplicacionPago.Importe = rowDD.Importe;
                rowAplicacionPago.IdTipoDeComprobanteDestino = rowDD.IdTipoDeComprobante;
                rowAplicacionPago.CuotaDestino       = rowDD.Cuota;
                rowAplicacionPago.IdEmpresa          = Security.IdEmpresa;
                rowAplicacionPago.IdSucursal         = Security.IdSucursal;
                rowAplicacionPago.FechaCreacion      = mz.erp.businessrules.Sistema.DateTime.Now;
                rowAplicacionPago.IdConexionCreacion = Security.IdConexion;
                //rowAplicacionPago.UltimaModificacion = null;
                rowAplicacionPago.IdConexionUltimaModificacion = Security.IdConexion;
                rowAplicacionPago.IdReservado = 0;
                rowAplicacionPago.RowId       = Guid.Empty;
                _dataComprobante.tsa_AplicacionPagos.Addtsa_AplicacionPagosRow(rowAplicacionPago);
                //Actualizo el saldo del comprobante anulado, lo ponemos en 0
                rowDD.Saldo = 0;
                _dataComprobante.tsa_ComprobanteDetalleDeuda.ImportRow(rowDD);
            }
        }