protected override void ClosePeriodProc(FinPeriod financialPeriod) { PXSelectBase <APRegister> prebookedDocuments = new PXSelect < APRegister, Where < APRegister.voided, Equal <False>, And <APRegister.prebooked, Equal <True>, And <APRegister.released, Equal <False>, And <APRegister.finPeriodID, Equal <Required <APRegister.finPeriodID> > > > > > >(this); if (prebookedDocuments.Any(financialPeriod.FinPeriodID)) { throw new PXException(Messages.PeriodHasPrebookedDocs); } PXSelectBase <APRegister> unreleasedDocuments = new PXSelectJoin < APRegister, LeftJoin <APAdjust, On <APAdjust.adjgDocType, Equal <APRegister.docType>, And <APAdjust.adjgRefNbr, Equal <APRegister.refNbr>, And <APAdjust.released, Equal <False> > > > >, Where < APRegister.voided, Equal <False>, And <APRegister.scheduled, Equal <False>, And <APRegister.rejected, Equal <False>, And <Where < APAdjust.adjgFinPeriodID, IsNull, And <APRegister.released, Equal <False>, And <APRegister.finPeriodID, Equal <Required <APRegister.finPeriodID> >, Or <APAdjust.adjgFinPeriodID, Equal <Required <APAdjust.adjgFinPeriodID> > > > > > > > > > >(this); if (unreleasedDocuments.Any(financialPeriod.FinPeriodID, financialPeriod.FinPeriodID)) { throw new PXException(Messages.PeriodHasUnreleasedDocs); } LandedCostTran landedCostTransactions = PXSelectJoin < LandedCostTran, InnerJoin <POReceipt, On <LandedCostTran.pOReceiptNbr, Equal <POReceipt.receiptNbr> > >, Where < LandedCostTran.source, Equal <LandedCostTranSource.fromPO>, And <POReceipt.released, Equal <True>, And <LandedCostTran.postponeAP, Equal <False>, And <LandedCostTran.processed, Equal <False>, And <LandedCostTran.invoiceDate, GreaterEqual <Required <LandedCostTran.invoiceDate> >, And <LandedCostTran.invoiceDate, Less <Required <LandedCostTran.invoiceDate> > > > > > > > > .SelectWindowed(this, 0, 1, financialPeriod.StartDate, financialPeriod.EndDate); if (landedCostTransactions?.LCTranID != null) { throw new PXException(Messages.PeriodHasAPDocsFromPO_LCToBeCreated); } financialPeriod.APClosed = true; Caches[typeof(FinPeriod)].Update(financialPeriod); Actions.PressSave(); }
public static bool IsDocumentSchedulable(PXGraph graph, ARRegister document) { PXSelectBase <ARRegister> schedulableDocumentSelect = new PXSelectJoin < ARRegister, LeftJoin <GLVoucher, On <GLVoucher.refNoteID, Equal <ARRegister.noteID>, And <FeatureInstalled <FeaturesSet.gLWorkBooks> > > >, Where < ARRegister.docType, Equal <Required <ARRegister.docType> >, And <ARRegister.refNbr, Equal <Required <ARRegister.refNbr> >, And <GLVoucher.refNbr, IsNull, And <IsSchedulable <ARRegister> > > > > >(graph); return(schedulableDocumentSelect.Any(document.DocType, document.RefNbr)); }