Exemple #1
0
        public override global::System.Data.DataSet Clone()
        {
            DsSubConceptoFacturable cln = ((DsSubConceptoFacturable)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Exemple #2
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DsSubConceptoFacturable ds = new DsSubConceptoFacturable();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
        public void CalcularImporteOrdenRetiro()
        {
            Importe = 0;
            // Reviso si se trata de un concepto de facturación
            if (ConceptoFacturacionID != null)
            {
                // Se trata de un concepto de facturación. busco los datos de este
                ConceptoFacturacion         concepto  = new ConceptoFacturacion();
                TarifarioConceptoFacturable tarifario = new TarifarioConceptoFacturable();;
                concepto.GetOne(ConceptoFacturacionID ?? 0);

                Int32         EstadoCodigoBarras;
                ICodigoBarras codigoBarras = new CodigoBarras();

                EstadoCodigoBarras = codigoBarras.ObtieneEstado(CodigoBarras);

                //Se pueden cargar dos estados o el 7( Emitido Asignado) o el 8(Emitido Prevendido)
                //esto es asi porque cuando se validan las OR, es cuando se guardan los CB. FQuiroga

                if (EstadoCodigoBarras == (int)SisPack.EstadoCodigoBarras.EmitidoAsignado)//asignado
                {
                    // Busco los datos del código de barras (es para obtener un posible tarifario asociado al código de barras)
                    DsCodigosBarras dsCodigo             = new DsCodigosBarras();
                    Int32?          _TarifarioFleteID_CB = null;

                    if (CodigoBarras != "" && CodigoBarras != null)
                    {
                        SqlParameter pCodigoBarras = new SqlParameter("@CodigoBarras", Utiles.BaseDatos.StrToSql(CodigoBarras));

                        DsCodigosBarras dsCodigoBarras = new DsCodigosBarras();

                        Config.Conexion.LlenarTypeDataSet(dsCodigoBarras.Datos, System.Data.CommandType.StoredProcedure, "CodigoBarrasGetOne", pCodigoBarras);

                        if (dsCodigoBarras.Datos.Rows.Count > 0)
                        {
                            _TarifarioFleteID_CB = dsCodigoBarras.Datos[0].IsTarifarioFleteIDNull() ? 0 : dsCodigoBarras.Datos[0].TarifarioFleteID;
                        }
                    }
                    // Con el tarifario de concepto calculo los importes.
                    tarifario.GetOneForEmision(_TarifarioFleteID_CB ?? 0);
                    CalcularImporteConTarifario(tarifario);
                }
                else if (EstadoCodigoBarras == (int)SisPack.EstadoCodigoBarras.EmitidoPrevendido) // Se prevendio buscar tarifas de preventa
                {
                    // obtengo importes de preventa
                    DsSubConceptoFacturable ds            = new DsSubConceptoFacturable();
                    SqlParameter            pCodigoBarras = new SqlParameter("@CodigoBarras", CodigoBarras);
                    Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "ObtieneTarifaPreventaSEL", pCodigoBarras);
                    foreach (DsSubConceptoFacturable.DatosRow dr in ds.Datos.Rows)
                    {
                        switch (dr.SubConceptoFacturableID)
                        {
                        case (int)SisPack.SubConceptoFacturable.FleteNacional:
                            // Guardo el importe de flete para restarlo al final, porque es prevendido
                            ImporteFleteConvenioCB = dr.Importe;
                            Importe += dr.Importe;
                            break;
                        }
                    }
                }

                Importe = Utiles.Matematicas.Redondear(Importe, 2);
            }
        }
        public void CalcularImporte()
        {
            Importe = 0;
            // Reviso si se trata de un concepto de facturación
            if (ConceptoFacturacionID != null)
            {
                // Se trata de un concepto de facturación. busco los datos de este
                ConceptoFacturacion         concepto  = new ConceptoFacturacion();
                TarifarioConceptoFacturable tarifario = new TarifarioConceptoFacturable();;
                concepto.GetOne(ConceptoFacturacionID ?? 0);

                // Desarrollo de emision de facturas con codigos de barras. Si la factura no tiene codigos de barras, sigo el camino normal
                if (CodigoBarras == String.Empty || CodigoBarras == null)
                {
                    // Obtengo el tarifario a utilizar
                    // Reviso si el concepto de facturación tiene cargado un tarifario a utilizar
                    if (concepto.TarifarioConceptoFacturableID != null)
                    {
                        // El concepto de facturación tiene cargado un tarifario. Utilizo este para el calculo
                        tarifario.GetOneForEmision(concepto.TarifarioConceptoFacturableID ?? 0);
                    }
                    else
                    {
                        // El concepto de facturación no tiene cargado un tarifario. Busco el tarifario predeterminado
                        tarifario.GetTarifarioPredeterminado(concepto.TipoTarifarioConceptoFacturableID ?? 0);
                        tarifario.GetOneForEmision(tarifario.TarifarioConceptoFacturableID ?? 0);
                    }

                    // Controlo el tarifario
                    if (tarifario.TarifarioConceptoFacturableID == null)
                    {
                        throw new Exception("Datos inválidos: El concepto " + concepto.Descripcion + " no tiene configurado un tarifario y no se encuentra uno general");
                    }
                    else if (tarifario.Baja ?? false)
                    {
                        throw new Exception("Datos inválidos: El tarifario del concepto " + concepto.Descripcion + " está dado de baja");
                    }

                    CalcularImporteConTarifario(tarifario);
                    // Se comenta el codigo de abajo, se saca en el metodo CalcularImporteConTarifario
                    //// Calculo el importe
                    //if (tarifario.EsTarifarioImporteFijo == false)
                    //{
                    //    Double cantExcedente = 0;
                    //    // Busco el tope a utilizar
                    //    ITarifarioConceptoFacturableTope _tope = (from t in tarifario.LstTopes
                    //                                              where (t.Tope ?? 0) >= (Tope ?? 0)
                    //                                              select t).OrderBy(x => x.Tope).FirstOrDefault();
                    //    if (_tope == null)
                    //    {
                    //        // No se encontro un tope. Esto quiere decir que se exede el máximo definido. Se trabaja con el máximo tope y se cobra el excedente
                    //        _tope = tarifario.LstTopes.OrderBy(x => x.Tope).LastOrDefault();
                    //        cantExcedente = (Tope ?? 0) - (_tope.Tope ?? 0);
                    //    }

                    //    if (_tope != null)
                    //    {
                    //        //if (tarifario.TarifarioConceptoFacturableRefID == null)
                    //        if (tarifario.TipoTarifarioConceptoFacturableID == (int)SisPack.TipoTarifarioConceptoFacturable.Tarifariosporbultos)
                    //        {
                    //            if (cantExcedente > 0)
                    //            {
                    //                Importe = (_tope.Valor * (Tope - cantExcedente) ?? 0);
                    //                Importe = Importe + (cantExcedente * (tarifario.ValorTopeAdicional ?? 0));
                    //            }
                    //            else
                    //            {
                    //                Importe = (_tope.Valor * Tope ?? 0);
                    //            }
                    //        }
                    //        else
                    //        {
                    //            //Modificado para que tome la modificacion de medida adicional
                    //            Importe = (_tope.Valor ?? 0) + (Math.Ceiling((Math.Round(cantExcedente, 4) / tarifario.MedidaAdicional ?? 1)) * (tarifario.ValorTopeAdicional ?? 0));
                    //            //Importe = (_tope.Valor ?? 0) + (cantExcedente * (tarifario.ValorTopeAdicional ?? 0));
                    //            //Importe = (_tope.ValorConVaricionTarifarioRef ?? 0) + (cantExcedente * (tarifario.ValorTopeAdicional ?? 0));
                    //        }
                    //    }
                    //    else
                    //    {
                    //        throw new Exception("Error en el tarifario. No se encontró un tope a utilizar");
                    //    }
                    //}
                    //else
                    //{
                    //    // Se trata de un tarifario con importe fijo
                    //    if (tarifario.TarifarioConceptoFacturableRefID == null)
                    //    {
                    //        Importe = tarifario.ValorImporteFijo ?? 0;
                    //    }
                    //    else
                    //    {
                    //        //tarifario.GetImporteFijoTarifarioReferencia(tarifario.TarifarioConceptoFacturableRefID ?? 0);
                    //        Importe = tarifario.ValorImporteFijoAjustado ?? 0;
                    //    }
                    //}
                }
                // Desarrollo de emision de facturas con codigos de barras. La factura tiene codigos de barras, busco tarifas de preventa, o tarifario asignado, dependiendo del tipo de asignacion
                else
                {
                    Int32         EstadoCodigoBarras;
                    ICodigoBarras codigoBarras = new CodigoBarras();
                    EstadoCodigoBarras = codigoBarras.ObtieneEstado(CodigoBarras);

                    //Se asigno buscar tarifario de concepto facturacion
                    if (EstadoCodigoBarras == (int)SisPack.EstadoCodigoBarras.AsignadoAgencia || EstadoCodigoBarras == (int)SisPack.EstadoCodigoBarras.AsignadoCliente)//asignado
                    {
                        // Busco los datos del código de barras (es para obtener un posible tarifario asociado al código de barras)
                        DsCodigosBarras dsCodigo             = new DsCodigosBarras();
                        Int32?          _TarifarioFleteID_CB = null;

                        if (CodigoBarras != "" && CodigoBarras != null)
                        {
                            SqlParameter pCodigoBarras = new SqlParameter("@CodigoBarras", Utiles.BaseDatos.StrToSql(CodigoBarras));

                            DsCodigosBarras dsCodigoBarras = new DsCodigosBarras();

                            Config.Conexion.LlenarTypeDataSet(dsCodigoBarras.Datos, System.Data.CommandType.StoredProcedure, "CodigoBarrasGetOne", pCodigoBarras);

                            if (dsCodigoBarras.Datos.Rows.Count > 0)
                            {
                                _TarifarioFleteID_CB = dsCodigoBarras.Datos[0].IsTarifarioFleteIDNull() ? 0 : dsCodigoBarras.Datos[0].TarifarioFleteID;
                            }
                        }
                        // Con el tarifario de concepto calculo los importes.
                        tarifario.GetOneForEmision(_TarifarioFleteID_CB ?? 0);
                        CalcularImporteConTarifario(tarifario);
                    }
                    else if (EstadoCodigoBarras == (int)SisPack.EstadoCodigoBarras.Prevendido) // Se prevendio buscar tarifas de preventa
                    {
                        // obtengo importes de preventa
                        DsSubConceptoFacturable ds            = new DsSubConceptoFacturable();
                        SqlParameter            pCodigoBarras = new SqlParameter("@CodigoBarras", CodigoBarras);
                        Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "ObtieneTarifaPreventaSEL", pCodigoBarras);
                        foreach (DsSubConceptoFacturable.DatosRow dr in ds.Datos.Rows)
                        {
                            switch (dr.SubConceptoFacturableID)
                            {
                            case (int)SisPack.SubConceptoFacturable.FleteNacional:
                                // Guardo el importe de flete para restarlo al final, porque es prevendido
                                ImporteFleteConvenioCB = dr.Importe;
                                Importe += dr.Importe;
                                break;
                            }
                        }
                    }
                }
            }

            Importe = Utiles.Matematicas.Redondear(Importe, 2);
        }
Exemple #5
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                DsSubConceptoFacturable ds = new DsSubConceptoFacturable();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "DatosDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }