コード例 #1
0
ファイル: BookMaint.cs プロジェクト: Vialythen/AcumaticaTest
 protected virtual void showCalendar()
 {
     if (Book.Current.UpdateGL == true)
     {
         FiscalYearSetupMaint graph = CreateInstance <FiscalYearSetupMaint>();
         graph.FiscalYearSetup.Current = graph.FiscalYearSetup.Select();
         if (graph.FiscalYearSetup.Current == null)
         {
             FinYearSetup calendar = new FinYearSetup();
             graph.FiscalYearSetup.Cache.Insert(calendar);
             graph.FiscalYearSetup.Cache.IsDirty = false;
         }
         throw new PXRedirectRequiredException(graph, Messages.Calendar);
     }
     else
     {
         FABookYearSetupMaint graph = CreateInstance <FABookYearSetupMaint>();
         graph.FiscalYearSetup.Current = graph.FiscalYearSetup.Search <FABookYearSetup.bookID>(Book.Current.BookCode);
         if (graph.FiscalYearSetup.Current == null)
         {
             FABookYearSetup calendar = new FABookYearSetup {
                 BookID = Book.Current.BookID
             };
             graph.FiscalYearSetup.Cache.SetDefaultExt <FABookYearSetup.periodType>(calendar);
             graph.FiscalYearSetup.Cache.Insert(calendar);
             graph.FiscalYearSetup.Cache.IsDirty = false;
         }
         throw new PXRedirectRequiredException(graph, Messages.Calendar);
     }
 }
コード例 #2
0
        protected virtual void FAOrganizationBook_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            FAOrganizationBook book = (FAOrganizationBook)e.Row;

            if (book == null)
            {
                return;
            }

            PXSetPropertyException disableRowException = null;
            FABookYearSetup        setup = PXSelect <FABookYearSetup, Where <FABookYearSetup.bookID, Equal <Current <FAOrganizationBook.bookID> > > > .SelectSingleBound(this, new object[] { book });

            if (setup == null && book.UpdateGL != true)
            {
                disableRowException = new PXSetPropertyException(Messages.CalendarSetupNotFound, PXErrorLevel.RowWarning, book.BookCode);
            }

            OrganizationFinYear nearestFinYear = FinPeriodRepository.FindNearestOrganizationFinYear(book.OrganizationID, "1900");

            if (disableRowException == null &&
                book.OrganizationID != FinPeriod.organizationID.MasterValue &&
                book.UpdateGL == true &&
                nearestFinYear == null)
            {
                disableRowException = new PXSetPropertyException(GL.Messages.OrganizationCalendarDoesNotExist, PXErrorLevel.RowWarning, PXAccess.GetOrganizationCD(book.OrganizationID));
            }

            if (disableRowException != null)
            {
                PXUIFieldAttribute.SetEnabled <FAOrganizationBook.selected>(sender, book, false);
                sender.RaiseExceptionHandling <FAOrganizationBook.selected>(book, null, disableRowException);
            }
        }
コード例 #3
0
        protected override void TYearSetupOnRowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            base.TYearSetupOnRowSelected(cache, e);
            FABookYearSetup yearSetup = (FABookYearSetup)e.Row;
            FABookBalance   bal       = PXSelect <FABookBalance, Where <FABookBalance.bookID, Equal <Current <FABookYearSetup.bookID> > > > .SelectSingleBound(this, new object[] { yearSetup });

            FABookYear year = null;

            if (bal == null)
            {
                year = PXSelect <FABookYear, Where <FABookYear.bookID, Equal <Current <FABookYearSetup.bookID> > > > .SelectSingleBound(this, new object[] { yearSetup });
            }
            DeleteGeneratedPeriods.SetEnabled(bal == null && year != null);
        }
コード例 #4
0
        public virtual IEnumerable deleteGeneratedPeriods(PXAdapter adapter)
        {
            FABookYearSetup year = FiscalYearSetup.Current;

            PXLongOperation.StartOperation(this, delegate
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PXDatabase.Delete <FABookYear>(new PXDataFieldRestrict("BookID", PXDbType.Int, 4, year.BookID, PXComp.EQ));
                    PXDatabase.Delete <FABookPeriod>(new PXDataFieldRestrict("BookID", PXDbType.Int, 4, year.BookID, PXComp.EQ));
                    ts.Complete();
                }
            });
            return(adapter.Get());
        }
コード例 #5
0
        protected virtual void FABook_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            FABook book = (FABook)e.Row;

            if (book == null)
            {
                return;
            }

            FABookYearSetup setup = PXSelect <FABookYearSetup, Where <FABookYearSetup.bookID, Equal <Current <FABook.bookID> > > > .SelectSingleBound(this, new object[] { book });

            if (setup == null && book.UpdateGL != true)
            {
                PXUIFieldAttribute.SetEnabled <FABook.selected>(sender, book, false);
                sender.RaiseExceptionHandling <FABook.selected>(book, null, new PXSetPropertyException(Messages.CalendarSetupNotFound, PXErrorLevel.RowWarning, book.BookCode));
            }
        }
コード例 #6
0
ファイル: BookMaint.cs プロジェクト: Vialythen/AcumaticaTest
        protected virtual void FABook_UpdateGL_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            FABook book = e.Row as FABook;

            if (book == null)
            {
                return;
            }

            if (Equals(e.NewValue, true))
            {
                FABookYearSetup setup = PXSelect <FABookYearSetup,
                                                  Where <FABookYearSetup.bookID, Equal <Current <FABook.bookID> > > > .SelectSingleBound(this, new object[] { book });

                if (setup != null)
                {
                    throw new PXSetPropertyException(Messages.UpdateGLBookHasFACalendar, PXErrorLevel.RowError, book.BookCode);
                }
            }
        }
コード例 #7
0
        public virtual void GeneratePeriodsProc(BoundaryYears filter, List <FABook> books)
        {
            for (int i = 0; i < books.Count; ++i)
            {
                FABook book = books[i];

                FieldDefaulting.AddHandler <FABookYear.bookID>(delegate(PXCache sender, PXFieldDefaultingEventArgs e)
                {
                    if (!e.Cancel)
                    {
                        e.NewValue = book.BookID;
                    }
                    e.Cancel = true;
                });

                FieldDefaulting.AddHandler <FABookPeriod.bookID>(delegate(PXCache sender, PXFieldDefaultingEventArgs e)
                {
                    if (!e.Cancel)
                    {
                        e.NewValue = book.BookID;
                    }
                    e.Cancel = true;
                });

                bool yearcreated = false;

                FABookYear bookyear = PXSelect <FABookYear, Where <FABookYear.bookID, Equal <Current <FABook.bookID> > >, OrderBy <Desc <FABookYear.year> > > .SelectSingleBound(this, new object[] { book });

                FABookYear newYear = new FABookYear {
                    Year = bookyear != null ? bookyear.Year : null
                };

                if (book.UpdateGL == false)
                {
                    FABookYearSetup calendar = PXSelect <FABookYearSetup, Where <FABookYearSetup.bookID, Equal <Current <FABook.bookID> > > > .SelectSingleBound(this, new object[] { book });

                    IEnumerable periods = PXSelect <FABookPeriodSetup, Where <FABookPeriodSetup.bookID, Equal <Current <FABook.bookID> > > > .SelectMultiBound(this, new object[] { book });

                    while (newYear != null && string.Compare(newYear.Year, filter.YearTo) < 0)
                    {
                        newYear = FiscalYearCreator <FABookYear, FABookPeriod, FABookPeriodSetup> .CreateNextYear(this, calendar, periods.RowCast <FABookPeriodSetup>(), bookyear);

                        bookyear = newYear;

                        yearcreated |= newYear != null;
                    }

                    bookyear = PXSelect <FABookYear, Where <FABookYear.bookID, Equal <Current <FABook.bookID> > >, OrderBy <Asc <FABookYear.year> > > .SelectSingleBound(this, new object[] { book });

                    newYear = new FABookYear {
                        Year = bookyear != null ? bookyear.Year : null
                    };
                    while (newYear != null && string.Compare(newYear.Year, calendar.FirstFinYear) > 0)
                    {
                        newYear = FiscalYearCreator <FABookYear, FABookPeriod, FABookPeriodSetup> .CreatePrevYear(this, calendar, periods.RowCast <FABookPeriodSetup>(), bookyear);

                        bookyear = newYear;

                        yearcreated |= newYear != null;
                    }
                }
                else
                {
                    FinYearSetup calendar = PXSelect <FinYearSetup> .Select(this);

                    IEnumerable periods = PXSelect <FinPeriodSetup> .Select(this);

                    while (newYear != null && string.Compare(newYear.Year, filter.YearTo) < 0)
                    {
                        newYear = FiscalYearCreator <FABookYear, FABookPeriod, FinPeriodSetup> .CreateNextYear(this, calendar, periods.RowCast <FinPeriodSetup>(), bookyear);

                        bookyear = newYear;

                        yearcreated |= newYear != null;
                    }

                    bookyear = PXSelect <FABookYear, Where <FABookYear.bookID, Equal <Current <FABook.bookID> > >, OrderBy <Asc <FABookYear.year> > > .SelectSingleBound(this, new object[] { book });

                    newYear = new FABookYear {
                        Year = bookyear != null ? bookyear.Year : null
                    };
                    while (newYear != null && string.Compare(newYear.Year, calendar.FirstFinYear) > 0)
                    {
                        newYear = FiscalYearCreator <FABookYear, FABookPeriod, FinPeriodSetup> .CreatePrevYear(this, calendar, periods.RowCast <FinPeriodSetup>(), bookyear);

                        bookyear = newYear;

                        yearcreated |= newYear != null;
                    }
                }

                if (!IsImport)
                {
                    if (yearcreated)
                    {
                        PXProcessing <FABook> .SetInfo(i, ActionsMessages.RecordProcessed);
                    }
                    else
                    {
                        PXProcessing <FABook> .SetWarning(i, Messages.CalendarAlreadyExists);
                    }
                }
            }

            Actions.PressSave();
        }
コード例 #8
0
        protected override bool AllowSetupModification(FABookYearSetup aRow)
        {
            bool isBookPresent = FiscalYearSetup.Current.BookID != null;

            return(isBookPresent);
        }