示例#1
0
        public virtual void ClosePeriodProc(FinPeriod p)
        {
            FiscalPeriod_ID.Current = p;

            PostGraph pg = PXGraph.CreateInstance <PostGraph>();

            foreach (PXResult <Batch, BatchCopy> res in PXSelectJoin <Batch, LeftJoin <BatchCopy, On <BatchCopy.origModule, Equal <Batch.module>, And <BatchCopy.origBatchNbr, Equal <Batch.batchNbr>, And <BatchCopy.autoReverseCopy, Equal <True> > > > >, Where <Batch.finPeriodID, Equal <Required <Batch.finPeriodID> >, And <Batch.autoReverse, Equal <True>, And <Batch.released, Equal <True>, And <BatchCopy.origBatchNbr, IsNull> > > > > .Select(this, p.FinPeriodID))
            {
                pg.Clear();
                Batch copy = pg.ReverseBatchProc((Batch)res);
                pg.ReleaseBatchProc(copy);

                if (glsetup.Current.AutoPostOption == true)
                {
                    pg.PostBatchProc(copy);
                }
            }

            if (Unreleased != null || Unposted != null)
            {
                throw new PXException(Messages.PeriodHasUnpostedBatches);
            }

            using (PXTransactionScope ts = new PXTransactionScope())
            {
                p.Closed     = true;
                p.DateLocked = true;
                p.APClosed   = true;
                p.ARClosed   = true;
                p.INClosed   = true;
                p.CAClosed   = true;
                p.FAClosed   = true;
                Caches[typeof(FinPeriod)].Update(p);

                if (Unclosed == null)
                {
                    if ((FinPeriod)NextFiscalYear.Select(p.FinYear) == null)
                    {
                        throw new PXException(Messages.NoPeriodsForNextYear);
                    }

                    CloseYearProc(p);
                }

                Caches[typeof(FinPeriod)].Persist(PXDBOperation.Update);
                Caches[typeof(FinPeriod)].Persisted(false);
                ts.Complete();
            }
        }
示例#2
0
 public static void ReleaseBatch(PostGraph pg, Batch batch)
 {
     pg.Clear();
     pg.ReleaseBatchProc(batch);
     if ((bool)batch.AutoReverse)
     {
         Batch copy = pg.ReverseBatchProc(batch);
         if (pg.AutoPost)
         {
             pg.PostBatchProc(batch);
         }
         pg.Clear();
         pg.TimeStamp = copy.tstamp;
         pg.ReleaseBatchProc(copy);
         if (pg.AutoPost)
         {
             pg.PostBatchProc(copy);
         }
     }
     else if (pg.AutoPost)
     {
         pg.PostBatchProc(batch);
     }
 }