예제 #1
0
        private void defaultCuryRate(PXCache cache, bool ForceDefault)
        {
            CurrencyRate rate = getCuryRate(cache);

            if (rate != null)
            {
                DateTime?UserCuryEffDate = CuryEffDate;

                CuryEffDate = rate.CuryEffDate;
                CuryRate    = Math.Round((decimal)rate.CuryRate, 8);
                CuryMultDiv = rate.CuryMultDiv;
                RecipRate   = Math.Round((decimal)rate.RateReciprocal, 8);

                if (rate.CuryEffDate < UserCuryEffDate)
                {
                    CurrencyRateType ratetype = (CurrencyRateType)PXSelectorAttribute.Select <CurrencyInfo.curyRateTypeID>(cache, this);
                    if (ratetype != null && ratetype.RateEffDays > 0 && ((TimeSpan)(UserCuryEffDate - rate.CuryEffDate)).Days >= ratetype.RateEffDays)
                    {
                        throw new PXRateIsNotDefinedForThisDateException(rate.CuryRateType, rate.FromCuryID, rate.ToCuryID, (DateTime)UserCuryEffDate);
                    }
                }
            }
            else if (ForceDefault)
            {
                if (string.Equals(this.CuryID, this.BaseCuryID, StringComparison.OrdinalIgnoreCase))
                {
                    bool         dirty = cache.IsDirty;
                    CurrencyInfo dflt  = new CurrencyInfo();
                    cache.SetDefaultExt <CurrencyInfo.curyRate>(dflt);
                    cache.SetDefaultExt <CurrencyInfo.curyMultDiv>(dflt);
                    cache.SetDefaultExt <CurrencyInfo.recipRate>(dflt);
                    CuryRate      = Math.Round((decimal)dflt.CuryRate, 8);
                    CuryMultDiv   = dflt.CuryMultDiv;
                    RecipRate     = Math.Round((decimal)dflt.RecipRate, 8);
                    cache.IsDirty = dirty;
                }
                else if (this._CuryRateTypeID == null || this._CuryEffDate == null)
                {
                    this.CuryRate    = null;
                    this.RecipRate   = null;
                    this.CuryMultDiv = "M";
                }
                else
                {
                    this.CuryRate    = null;
                    this.RecipRate   = null;
                    this.CuryMultDiv = "M";
                    throw new PXSetPropertyException(Messages.RateNotFound, PXErrorLevel.Warning);
                }
            }
        }
예제 #2
0
        protected virtual IEnumerable currencyRateList()
        {
            foreach (PXResult <CurrencyList, CurrencyRateType> res in PXSelectJoin <CurrencyList,
                                                                                    CrossJoin <CurrencyRateType>, Where <CurrencyRateType.refreshOnline, Equal <boolTrue>,
                                                                                                                         And <CurrencyList.isActive, Equal <boolTrue>,
                                                                                                                              And <CurrencyList.curyID, NotEqual <Current <RefreshFilter.curyID> >,
                                                                                                                                   And <Where <CurrencyRateType.curyRateTypeID, Equal <Current <RefreshFilter.curyRateTypeID> >, Or <Current <RefreshFilter.curyRateTypeID>, IsNull> > > > > > > .Select(this))
            {
                CurrencyList     curr     = res;
                CurrencyRateType rateType = res;

                RefreshRate rate = new RefreshRate();
                rate.FromCuryID           = curr.CuryID;
                rate.CuryRateType         = rateType.CuryRateTypeID;
                rate.OnlineRateAdjustment = rateType.OnlineRateAdjustment;

                CurrencyRateList.Cache.SetStatus(rate, PXEntryStatus.Held);
                yield return(rate);
            }
        }