public static ExpedienteList GetListFomento(string cod_aduanero,
                                                    NavieraInfo naviera,
                                                    PuertoInfo p_origen,
                                                    PuertoInfo p_destino,
                                                    DateTime from,
                                                    DateTime till)
        {
            CriteriaEx criteria = Expedient.GetCriteria(Expedient.OpenSession());

            criteria.Childs = false;

            //No criteria. Retrieve all de List

            if (nHManager.Instance.UseDirectSQL)
            {
                criteria.Query = ExpedienteList.SELECT_FOMENTO(cod_aduanero,
                                                               naviera,
                                                               p_origen,
                                                               p_destino,
                                                               from,
                                                               till);
            }

            ExpedienteList list = DataPortal.Fetch <ExpedienteList>(criteria);

            CloseSession(criteria.SessionCode);
            return(list);
        }
예제 #2
0
        /// <summary>
        /// Copia los atributos del objeto
        /// </summary>
        /// <param name="source">Objeto origen</param>
        protected void CopyValues(NavieraInfo source)
        {
            if (source == null)
            {
                return;
            }

            _base.CopyValues(source);
            Oid = source.Oid;
        }
예제 #3
0
        public void CopyValues(NavieraInfo source)
        {
            if (source == null)
            {
                return;
            }

            _record.CopyValues(source.Base.Record);
            _provider_base.CopyCommonValues(source);

            _provider_base.OidAcreedor = _record.Oid;
        }
        public static string SELECT_FOMENTO(string cod_aduanero,
                                            NavieraInfo naviera,
                                            PuertoInfo p_origen,
                                            PuertoInfo p_destino,
                                            DateTime from,
                                            DateTime till)
        {
            QueryConditions conditions = new QueryConditions();

            string query = Expedient.FIELDS(conditions) +
                           Expedient.JOIN(conditions) +
                           Expedient.WHERE(conditions) +
                           " AND E.\"FECHA_CONOCIMIENTO\" >= '" + from.ToString("MM/dd/yyyy") + "'" +
                           " AND E.\"FECHA_CONOCIMIENTO\" <= '" + till.ToString("MM/dd/yyyy") + "'";

            if (cod_aduanero != string.Empty)
            {
                query += " AND E.\"CODIGO_ARTICULO\" = '" + cod_aduanero + "'";
            }
            if (naviera != null)
            {
                query += " AND E.\"OID_NAVIERA\" = " + naviera.Oid;
            }
            if (p_origen != null)
            {
                query += " AND E.\"PUERTO_ORIGEN\" = '" + p_origen.Valor + "'";
            }
            if (p_destino != null)
            {
                query += " AND E.\"PUERTO_DESTINO\" = '" + p_destino.Valor + "'";
            }

            query += " ORDER BY E.\"CODIGO\"";

            return(query);
        }
        public virtual void UpdateGastos(bool estimated = true)
        {
            if (Gastos == null)
            {
                return;
            }

            _base.GastosGenerales        = 0;
            _base.OtrosGastos            = 0;
            _base.Record.GProvTotal      = 0;
            _base.Record.GNavTotal       = 0;
            _base.Record.GDespTotal      = 0;
            _base.Record.GTransDestTotal = 0;
            _base.Record.GTransTotal     = 0;

            _base.Record.GProvTotal = Gastos.Where(x => x.ECategoriaGasto == ECategoriaGasto.Stock).Sum(x => x.Total);

            _base.Record.GNavTotal = Gastos.Where(x =>
                                                  x.ECategoriaGasto == ECategoriaGasto.GeneralesExpediente &&
                                                  x.ETipoAcreedor == ETipoAcreedor.Naviera
                                                  ).Sum(x => x.Total);

            _base.Record.GDespTotal = Gastos.Where(x =>
                                                   x.ECategoriaGasto == ECategoriaGasto.GeneralesExpediente &&
                                                   x.ETipoAcreedor == ETipoAcreedor.Despachante
                                                   ).Sum(x => x.Total);

            _base.Record.GTransDestTotal = Gastos.Where(x =>
                                                        x.ECategoriaGasto == ECategoriaGasto.GeneralesExpediente &&
                                                        x.ETipoAcreedor == ETipoAcreedor.TransportistaDestino
                                                        ).Sum(x => x.Total);

            _base.Record.GTransTotal = Gastos.Where(x =>
                                                    x.ECategoriaGasto == ECategoriaGasto.GeneralesExpediente &&
                                                    x.ETipoAcreedor == ETipoAcreedor.TransportistaOrigen
                                                    ).Sum(x => x.Total);

            _base.OtrosGastos += Gastos.Where(x =>
                                              !new List <ECategoriaGasto> {
                ECategoriaGasto.Stock, ECategoriaGasto.GeneralesExpediente
            }.Contains(x.ECategoriaGasto) &&
                                              x.OidFactura == 0
                                              ).Sum(x => x.Total);

            _base.OtrosGastosFacturas += Gastos.Where(x =>
                                                      !new List <ECategoriaGasto> {
                ECategoriaGasto.Stock, ECategoriaGasto.GeneralesExpediente
            }.Contains(x.ECategoriaGasto) &&
                                                      x.OidFactura != 0
                                                      ).Sum(x => x.Total);

            //Gastos por tipo de acreedor

            /*foreach (GastoInfo item in Gastos)
             * {
             *      switch (item.ECategoriaGasto)
             *      {
             *              case ECategoriaGasto.Stock:
             * _base.Record.GProvTotal += item.Total;
             *                      break;
             *
             *              case ECategoriaGasto.GeneralesExpediente:
             *
             *                      switch (item.ETipoAcreedor)
             *                      {
             *                              case ETipoAcreedor.Naviera:
             *      _base.Record.GNavTotal += item.Total;
             *                                      break;
             *
             *                              case ETipoAcreedor.Despachante:
             *      _base.Record.GDespTotal += item.Total;
             *                                      break;
             *
             *                              case ETipoAcreedor.TransportistaDestino:
             *      _base.Record.GTransTotal += item.Total;
             *                                      break;
             *
             *                              case ETipoAcreedor.TransportistaOrigen:
             *      _base.Record.GTransDestTotal += item.Total;
             *                                      break;
             *                      }
             *
             *                      break;
             *
             *              default:
             *                      _base.OtrosGastos += item.Total;
             *                      break;
             *      }
             * }*/

            //Gasto Estimado Naviera
            if (GNavTotal == 0 && estimated)
            {
                NavieraInfo nav = NavieraInfo.Get(OidNaviera, true);
                if (nav != null)
                {
                    PrecioTrayectoInfo precio = nav.PrecioTrayectos.GetByPorts(PuertoOrigen, PuertoDestino);
                    _base.Record.GNavTotal = (precio != null) ? precio.Precio : 0;
                    _base.Record.GNavFac   = Resources.Defaults.ESTIMADO;
                }
            }

            //Gasto Estimado Tranporte Origen
            if (GTransTotal == 0 && estimated)
            {
                TransporterInfo tr = TransporterInfo.Get(OidTransOrigen, ETipoAcreedor.TransportistaOrigen, true);
                if (tr != null)
                {
                    PrecioOrigenInfo precio = tr.PrecioOrigenes.GetByProvAndPort(OidProveedor, PuertoOrigen);
                    _base.Record.GTransTotal = (precio != null) ? precio.Precio : 0;
                    _base.Record.GTransFac   = Resources.Defaults.ESTIMADO;
                }
            }

            //Gasto Estimado Despachante
            if (GDespTotal == 0 && estimated)
            {
                DespachanteInfo des = DespachanteInfo.Get(OidDespachante, false);
                if (des != null)
                {
                    //PrecioTrayectoInfo precio = nav.PrecioTrayectos.GetByPorts(PuertoOrigen, PuertoDestino);
                    _base.Record.GDespTotal = 50; //(precio != null) ? precio.Precio : 0;
                    _base.Record.GDespFac   = Resources.Defaults.ESTIMADO;
                }
            }

            //Gasto Estimado Transporte Destino
            if (GTransDestTotal == 0 && estimated)
            {
                TransporterInfo tr = TransporterInfo.Get(OidTransDestino, ETipoAcreedor.TransportistaDestino, true);
                if (tr != null)
                {
                    PrecioDestinoInfo precio = tr.PrecioDestinos.GetByPort(PuertoDestino);
                    _base.Record.GTransDestTotal = (precio != null) ? precio.Precio : 0;
                    _base.Record.GTransDestFac   = Resources.Defaults.ESTIMADO;
                }
            }

            _base.GastosGenerales += GNavTotal + GDespTotal + GTransDestTotal + GTransTotal;
        }
예제 #6
0
 public static string SELECT(NavieraInfo parent)
 {
     return(SELECT(new QueryConditions {
         Naviera = parent
     }));
 }