Beispiel #1
0
        public virtual IEnumerable araccountlist()
        {
            foreach (PXResult <ARHistoryByPeriod, RevaluedARHistory, Account, Customer> res in PXSelectJoin <ARHistoryByPeriod,
                                                                                                             InnerJoin <RevaluedARHistory,
                                                                                                                        On <RevaluedARHistory.customerID, Equal <ARHistoryByPeriod.customerID>,
                                                                                                                            And <RevaluedARHistory.branchID, Equal <ARHistoryByPeriod.branchID>,
                                                                                                                                 And <RevaluedARHistory.accountID, Equal <ARHistoryByPeriod.accountID>,
                                                                                                                                      And <RevaluedARHistory.subID, Equal <ARHistoryByPeriod.subID>,
                                                                                                                                           And <RevaluedARHistory.curyID, Equal <ARHistoryByPeriod.curyID>,
                                                                                                                                                And <RevaluedARHistory.finPeriodID, Equal <ARHistoryByPeriod.lastActivityPeriod> > > > > > >,
                                                                                                                        LeftJoin <Account, On <Account.accountID, Equal <ARHistoryByPeriod.accountID>, And <Account.curyID, IsNotNull> >,
                                                                                                                                  InnerJoin <Customer, On <Customer.bAccountID, Equal <ARHistoryByPeriod.customerID> > > > >,
                                                                                                             Where <ARHistoryByPeriod.curyID, Equal <Current <RevalueFilter.curyID> >,
                                                                                                                    And <ARHistoryByPeriod.finPeriodID, Equal <Current <RevalueFilter.finPeriodID> >,
                                                                                                                         And <Account.accountID, IsNull,
                                                                                                                              And <RevaluedARHistory.curyFinYtdBalance, NotEqual <decimal0> >
                                                                                                                              > > > > .Select(this))
            {
                ARHistoryByPeriod histbyper = res;
                RevaluedARHistory hist      = PXCache <RevaluedARHistory> .CreateCopy(res);

                RevaluedARHistory existing;
                Customer          cust = res;

                if ((existing = ARAccountList.Locate(hist)) != null)
                {
                    yield return(existing);

                    continue;
                }
                else
                {
                    ARAccountList.Cache.SetStatus(hist, PXEntryStatus.Held);
                }

                hist.CustomerClassID = cust.CustomerClassID;
                hist.CuryRateTypeID  = cmsetup.Current.ARRateTypeReval ?? cust.CuryRateTypeID;

                if (string.IsNullOrEmpty(hist.CuryRateTypeID))
                {
                    ARAccountList.Cache.RaiseExceptionHandling <RevaluedGLHistory.curyRateTypeID>(hist, null, new PXSetPropertyException(Messages.RateTypeNotFound));
                }
                else
                {
                    CurrencyRateByDate curyrate = PXSelect <CurrencyRateByDate,
                                                            Where <CurrencyRateByDate.fromCuryID, Equal <Current <RevalueFilter.curyID> >,
                                                                   And <CurrencyRateByDate.toCuryID, Equal <Current <Company.baseCuryID> >,
                                                                        And <CurrencyRateByDate.curyRateType, Equal <Required <Customer.curyRateTypeID> >,
                                                                             And2 <Where <CurrencyRateByDate.curyEffDate, LessEqual <Current <RevalueFilter.curyEffDate> >, Or <CurrencyRateByDate.curyEffDate, IsNull> >, And <Where <CurrencyRateByDate.nextEffDate, Greater <Current <RevalueFilter.curyEffDate> >, Or <CurrencyRateByDate.nextEffDate, IsNull> > > > > > > >
                                                  .Select(this, hist.CuryRateTypeID);

                    if (curyrate == null || curyrate.CuryMultDiv == null)
                    {
                        hist.CuryMultDiv = "M";
                        hist.CuryRate    = 1m;
                        ARAccountList.Cache.RaiseExceptionHandling <RevaluedARHistory.curyRate>(hist, 1m, new PXSetPropertyException(Messages.RateNotFound, PXErrorLevel.RowWarning));
                    }
                    else
                    {
                        hist.CuryRate    = curyrate.CuryRate;
                        hist.CuryMultDiv = curyrate.CuryMultDiv;
                    }

                    CurrencyInfo info = new CurrencyInfo();
                    info.BaseCuryID  = company.Current.BaseCuryID;
                    info.CuryID      = hist.CuryID;
                    info.CuryMultDiv = hist.CuryMultDiv;
                    info.CuryRate    = hist.CuryRate;

                    //hist.CuryFinYtdBalance -= hist.CuryFinYtdDeposits;
                    //hist.FinYtdBalance -= hist.FinYtdDeposits;

                    decimal baseval;
                    PXCurrencyAttribute.CuryConvBase(currencyinfo.Cache, info, (decimal)hist.CuryFinYtdBalance, out baseval);
                    hist.FinYtdRevalued  = baseval;
                    hist.FinPrevRevalued = string.Equals(histbyper.FinPeriodID, histbyper.LastActivityPeriod) ? hist.FinPtdRevalued : 0m;
                    hist.FinPtdRevalued  = hist.FinYtdRevalued - hist.FinPrevRevalued - hist.FinYtdBalance;
                }
                yield return(hist);
            }
        }
        public virtual IEnumerable glaccountlist()
        {
            foreach (PXResult <GLHistoryByPeriod, RevaluedGLHistory, Account, Branch, FinPeriod, GLHistoryLastRevaluation> res in
                     PXSelectJoin <GLHistoryByPeriod,
                                   InnerJoin <RevaluedGLHistory,
                                              On <RevaluedGLHistory.ledgerID, Equal <GLHistoryByPeriod.ledgerID>,
                                                  And <RevaluedGLHistory.branchID, Equal <GLHistoryByPeriod.branchID>,
                                                       And <RevaluedGLHistory.accountID, Equal <GLHistoryByPeriod.accountID>,
                                                            And <RevaluedGLHistory.subID, Equal <GLHistoryByPeriod.subID>,
                                                                 And <RevaluedGLHistory.finPeriodID, Equal <GLHistoryByPeriod.lastActivityPeriod> > > > > >,
                                              InnerJoin <Account,
                                                         On <Account.accountID, Equal <GLHistoryByPeriod.accountID> >,
                                                         InnerJoin <Branch,
                                                                    On <Branch.branchID, Equal <GLHistoryByPeriod.branchID>,
                                                                        And <Branch.ledgerID, Equal <GLHistoryByPeriod.ledgerID> > >,
                                                                    InnerJoin <FinPeriod,
                                                                               On <GLHistoryByPeriod.finPeriodID, Equal <FinPeriod.finPeriodID>,
                                                                                   And <Branch.organizationID, Equal <FinPeriod.organizationID> > >,
                                                                               LeftJoin <GLHistoryLastRevaluation,
                                                                                         On <GLHistoryByPeriod.ledgerID, Equal <GLHistoryLastRevaluation.ledgerID>,
                                                                                             And <GLHistoryByPeriod.branchID, Equal <GLHistoryLastRevaluation.branchID>,
                                                                                                  And <GLHistoryByPeriod.accountID, Equal <GLHistoryLastRevaluation.accountID>,
                                                                                                       And <GLHistoryByPeriod.subID, Equal <GLHistoryLastRevaluation.subID> > > > > > > > > >,
                                   Where <Account.curyID, Equal <Current <RevalueFilter.curyID> >,
                                          And <FinPeriod.masterFinPeriodID, Equal <Current <RevalueFilter.finPeriodID> >,
                                               And <Where <RevaluedGLHistory.curyFinYtdBalance, NotEqual <decimal0>,
                                                           Or <RevaluedGLHistory.finYtdBalance, NotEqual <decimal0> > > > > > >
                     .Select(this))
            {
                GLHistoryByPeriod        histbyper             = res;
                GLHistoryLastRevaluation lastRevaluationPeriod = res;
                RevaluedGLHistory        hist = PXCache <RevaluedGLHistory> .CreateCopy(res);

                RevaluedGLHistory existing;

                if ((existing = GLAccountList.Locate(hist)) != null)
                {
                    yield return(existing);

                    continue;
                }
                else
                {
                    GLAccountList.Cache.SetStatus(hist, PXEntryStatus.Held);
                }

                if (string.IsNullOrEmpty(hist.CuryRateTypeID = ((Account)res).RevalCuryRateTypeId))
                {
                    hist.CuryRateTypeID = cmsetup.Current.GLRateTypeReval;
                }

                if (string.IsNullOrEmpty(hist.CuryRateTypeID))
                {
                    GLAccountList.Cache.RaiseExceptionHandling <RevaluedGLHistory.curyRateTypeID>(hist, null, new PXSetPropertyException(Messages.RateTypeNotFound));
                }
                else
                {
                    CurrencyRate curyrate = PXSelect <CurrencyRate,
                                                      Where <CurrencyRate.fromCuryID, Equal <Current <RevalueFilter.curyID> >,
                                                             And <CurrencyRate.toCuryID, Equal <Current <Company.baseCuryID> >,
                                                                  And <CurrencyRate.curyRateType, Equal <Required <Account.revalCuryRateTypeId> >,
                                                                       And <CurrencyRate.curyEffDate, LessEqual <Current <RevalueFilter.curyEffDate> > > > > >,
                                                      OrderBy <Desc <CurrencyRate.curyEffDate> > > .Select(this, hist.CuryRateTypeID);

                    if (curyrate == null || curyrate.CuryMultDiv == null)
                    {
                        hist.CuryMultDiv    = "M";
                        hist.CuryRate       = 1m;
                        hist.RateReciprocal = 1m;
                        hist.CuryEffDate    = Filter.Current.CuryEffDate;
                        GLAccountList.Cache.RaiseExceptionHandling <RevaluedGLHistory.curyRate>(hist, 1m, new PXSetPropertyException(Messages.RateNotFound, PXErrorLevel.RowWarning));
                    }
                    else
                    {
                        hist.CuryRate       = curyrate.CuryRate;
                        hist.RateReciprocal = curyrate.RateReciprocal;
                        hist.CuryEffDate    = curyrate.CuryEffDate;
                        hist.CuryMultDiv    = curyrate.CuryMultDiv;
                    }

                    CurrencyInfo info = new CurrencyInfo();
                    info.BaseCuryID  = company.Current.BaseCuryID;
                    info.CuryID      = hist.CuryID;
                    info.CuryMultDiv = hist.CuryMultDiv;
                    info.CuryRate    = hist.CuryRate;

                    decimal baseval;
                    PXCurrencyAttribute.CuryConvBase(currencyinfo.Cache, info, (decimal)hist.CuryFinYtdBalance, out baseval);
                    hist.FinYtdRevalued          = baseval;
                    hist.FinPtdRevalued          = hist.FinYtdRevalued - hist.FinYtdBalance;
                    hist.LastRevaluedFinPeriodID = lastRevaluationPeriod?.LastActivityPeriod;
                }

                yield return(hist);
            }
        }
Beispiel #3
0
        public virtual IEnumerable apaccountlist()
        {
            foreach (PXResult <APHistoryByPeriod, RevaluedAPHistory, Vendor, APHistoryLastRevaluation> res in
                     PXSelectJoin <APHistoryByPeriod,
                                   InnerJoin <RevaluedAPHistory,
                                              On <RevaluedAPHistory.vendorID, Equal <APHistoryByPeriod.vendorID>,
                                                  And <RevaluedAPHistory.branchID, Equal <APHistoryByPeriod.branchID>,
                                                       And <RevaluedAPHistory.accountID, Equal <APHistoryByPeriod.accountID>,
                                                            And <RevaluedAPHistory.subID, Equal <APHistoryByPeriod.subID>,
                                                                 And <RevaluedAPHistory.curyID, Equal <APHistoryByPeriod.curyID>,
                                                                      And <RevaluedAPHistory.finPeriodID, Equal <APHistoryByPeriod.lastActivityPeriod> > > > > > >,
                                              InnerJoin <Vendor,
                                                         On <Vendor.bAccountID, Equal <APHistoryByPeriod.vendorID> >,
                                                         LeftJoin <APHistoryLastRevaluation,
                                                                   On <APHistoryByPeriod.vendorID, Equal <APHistoryLastRevaluation.vendorID>,
                                                                       And <APHistoryByPeriod.branchID, Equal <APHistoryLastRevaluation.branchID>,
                                                                            And <APHistoryByPeriod.accountID, Equal <APHistoryLastRevaluation.accountID>,
                                                                                 And <APHistoryByPeriod.subID, Equal <APHistoryLastRevaluation.subID>,
                                                                                      And <APHistoryByPeriod.curyID, Equal <APHistoryLastRevaluation.curyID> > > > > > > > >,
                                   Where <APHistoryByPeriod.curyID, Equal <Current <RevalueFilter.curyID> >,
                                          And <APHistoryByPeriod.finPeriodID, Equal <Current <RevalueFilter.finPeriodID> >,
                                               And <Where <RevaluedAPHistory.curyFinYtdBalance, NotEqual <decimal0>,
                                                           Or <RevaluedAPHistory.finPtdRevalued, NotEqual <decimal0>,
                                                               Or <RevaluedAPHistory.curyFinYtdDeposits, NotEqual <decimal0> > > > > > > >
                     .Select(this))
            {
                APHistoryByPeriod        histbyper             = res;
                APHistoryLastRevaluation lastRevaluationPeriod = res;
                RevaluedAPHistory        hist = PXCache <RevaluedAPHistory> .CreateCopy(res);

                RevaluedAPHistory existing;
                Vendor            vendor = res;

                if ((existing = APAccountList.Locate(hist)) != null)
                {
                    yield return(existing);

                    continue;
                }
                else
                {
                    APAccountList.Cache.SetStatus(hist, PXEntryStatus.Held);
                }

                hist.VendorClassID  = vendor.VendorClassID;
                hist.CuryRateTypeID = cmsetup.Current.APRateTypeReval ?? ((Vendor)res).CuryRateTypeID;

                if (string.IsNullOrEmpty(hist.CuryRateTypeID))
                {
                    APAccountList.Cache.RaiseExceptionHandling <RevaluedGLHistory.curyRateTypeID>(hist, null, new PXSetPropertyException(Messages.RateTypeNotFound));
                }
                else
                {
                    CurrencyRate curyrate = PXSelect <CurrencyRate,
                                                      Where <CurrencyRate.fromCuryID, Equal <Current <RevalueFilter.curyID> >,
                                                             And <CurrencyRate.toCuryID, Equal <Current <Company.baseCuryID> >,
                                                                  And <CurrencyRate.curyRateType, Equal <Required <Vendor.curyRateTypeID> >,
                                                                       And <CurrencyRate.curyEffDate, LessEqual <Current <RevalueFilter.curyEffDate> > > > > >,
                                                      OrderBy <Desc <CurrencyRate.curyEffDate> > > .Select(this, hist.CuryRateTypeID);

                    if (curyrate == null || curyrate.CuryMultDiv == null)
                    {
                        hist.CuryMultDiv    = "M";
                        hist.CuryRate       = 1m;
                        hist.RateReciprocal = 1m;
                        hist.CuryEffDate    = Filter.Current.CuryEffDate;
                        APAccountList.Cache.RaiseExceptionHandling <RevaluedAPHistory.curyRate>(hist, 1m, new PXSetPropertyException(Messages.RateNotFound, PXErrorLevel.RowWarning));
                    }
                    else
                    {
                        hist.CuryRate       = curyrate.CuryRate;
                        hist.RateReciprocal = curyrate.RateReciprocal;
                        hist.CuryEffDate    = curyrate.CuryEffDate;
                        hist.CuryMultDiv    = curyrate.CuryMultDiv;
                    }

                    CurrencyInfo info = new CurrencyInfo();
                    info.BaseCuryID  = company.Current.BaseCuryID;
                    info.CuryID      = hist.CuryID;
                    info.CuryMultDiv = hist.CuryMultDiv;
                    info.CuryRate    = hist.CuryRate;
                    info.RecipRate   = hist.RateReciprocal;

                    hist.CuryFinYtdBalance -= hist.CuryFinYtdDeposits;
                    hist.FinYtdBalance     -= hist.FinYtdDeposits;

                    decimal baseval;
                    PXCurrencyAttribute.CuryConvBase(currencyinfo.Cache, info, (decimal)hist.CuryFinYtdBalance, out baseval);
                    hist.FinYtdRevalued          = baseval;
                    hist.FinPrevRevalued         = string.Equals(histbyper.FinPeriodID, histbyper.LastActivityPeriod) ? hist.FinPtdRevalued : 0m;
                    hist.FinPtdRevalued          = hist.FinYtdRevalued - hist.FinPrevRevalued - hist.FinYtdBalance;
                    hist.LastRevaluedFinPeriodID = lastRevaluationPeriod?.LastActivityPeriod;
                }
                yield return(hist);
            }
        }