private static string GetMessage(string financialPeriodId, int offset) { if (string.IsNullOrEmpty(financialPeriodId)) { return(Messages.NoPeriodsDefined); } else { switch (offset) { case 0: return(PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodWithId, FinPeriodIDAttribute.FormatForError(financialPeriodId))); case -1: return(PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodBefore, FinPeriodIDAttribute.FormatForError(financialPeriodId))); case 1: return(PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodAfter, FinPeriodIDAttribute.FormatForError(financialPeriodId))); default: return(PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodForOffset, Math.Abs(offset), offset > 0 ? Messages.AfterLowercase : Messages.BeforeLowercase, FinPeriodIDAttribute.FormatForError(financialPeriodId))); } } }
/// <param name="financialPeriodId"> /// The financial period ID in the internal representation. /// It will automatically be formatted for display in the error message. /// </param> public FinancialPeriodWithIdNotFoundException(string financialPeriodId) : base(string.IsNullOrEmpty(financialPeriodId) ? Messages.NoPeriodsDefined : PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodWithId, FinPeriodIDAttribute.FormatForError(financialPeriodId))) { FinancialPeriodId = financialPeriodId; }
/// <param name="financialPeriodId"> /// The financial period ID in the internal representation. /// It will automatically be formatted for display in the error message. /// </param> public FinancialPeriodOffsetNotFoundException(string financialPeriodId, int offset) : base(string.IsNullOrEmpty(financialPeriodId) ? Messages.NoPeriodsDefined : offset == 0 ? PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodWithId, FinPeriodIDAttribute.FormatForError(financialPeriodId)) : offset == -1 ? PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodBefore, FinPeriodIDAttribute.FormatForError(financialPeriodId)) : offset == 1 ? PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodAfter, FinPeriodIDAttribute.FormatForError(financialPeriodId)) : PXLocalizer.LocalizeFormat(Messages.NoFinancialPeriodForOffset, Math.Abs(offset), FinPeriodIDAttribute.FormatForError(financialPeriodId))) { FinancialPeriodId = financialPeriodId; Offset = offset; }
protected override void ClosePeriodProc(FinPeriod p) { PXSelectBase select = new PXSelect <FATran, Where <FATran.finPeriodID, Equal <Required <FATran.finPeriodID> >, And <FATran.released, Equal <False> > > >(this); FATran tran = (FATran)select.View.SelectSingle(p.FinPeriodID); if (tran != null) { throw new PXException(AP.Messages.PeriodHasUnreleasedDocs); } PXResult <FABookBalance, FixedAsset, FABook> res = (PXResult <FABookBalance, FixedAsset, FABook>) PXSelectJoin <FABookBalance, LeftJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >, LeftJoin <FABook, On <FABookBalance.bookID, Equal <FABook.bookID> >, LeftJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> > > > >, Where <FABookBalance.deprFromPeriod, LessEqual <Current <FinPeriod.finPeriodID> >, And <FABookBalance.deprToPeriod, GreaterEqual <Current <FinPeriod.finPeriodID> >, And <FABookBalance.updateGL, Equal <True>, And <FixedAsset.suspended, NotEqual <True>, And <FADetails.hold, NotEqual <True>, And <FABookBalance.initPeriod, IsNotNull, And <Where <FABookBalance.currDeprPeriod, IsNull, And <FABookBalance.status, Equal <FixedAssetStatus.active>, Or <FABookBalance.currDeprPeriod, LessEqual <Current <FinPeriod.finPeriodID> > > > > > > > > > > > > .SelectSingleBound(this, new object[] { p }); if (res != null) { FixedAsset asset = res; FABook book = res; throw new PXException(Messages.AssetNotDepreciatedInPeriod, asset.AssetCD, book.BookCode, FinPeriodIDAttribute.FormatForError(p.FinPeriodID)); } p.FAClosed = true; Caches[typeof(FinPeriod)].Update(p); Actions.PressSave(); }