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(); }
protected override void ClosePeriodProc(FinPeriod p) { PXSelectBase select = new PXSelect <INRegister, Where <INRegister.finPeriodID, Equal <Required <INRegister.finPeriodID> >, And <INRegister.released, Equal <boolFalse> > > >(this); INRegister doc = (INRegister)select.View.SelectSingle(p.FinPeriodID); if (doc != null) { throw new PXException(AP.Messages.PeriodHasUnreleasedDocs); } //MS Landed cost will not be able to create these transactions if the period is closed LandedCostTran lcTranFromAP = PXSelectJoin <LandedCostTran, InnerJoin <APRegister, On <LandedCostTran.aPDocType, Equal <APRegister.docType>, And <LandedCostTran.aPRefNbr, Equal <APRegister.refNbr> > > >, Where <LandedCostTran.invoiceDate, GreaterEqual <Required <LandedCostTran.invoiceDate> >, And <LandedCostTran.invoiceDate, Less <Required <LandedCostTran.invoiceDate> >, And <LandedCostTran.source, Equal <LandedCostTranSource.fromAP>, And <APRegister.released, Equal <True>, And <LandedCostTran.processed, Equal <False> > > > > > > .Select(this, p.StartDate, p.EndDate); if (lcTranFromAP != null && lcTranFromAP.LCTranID.HasValue) { throw new PXException(Messages.PeriodHasINDocsFromAP_LCToBeCreated); } PO.LandedCostTran lcTranFromPO = PXSelectJoin <LandedCostTran, InnerJoin <POReceipt, On <LandedCostTran.pOReceiptNbr, Equal <POReceipt.receiptNbr> > >, Where <LandedCostTran.invoiceDate, GreaterEqual <Required <LandedCostTran.invoiceDate> >, And <LandedCostTran.invoiceDate, Less <Required <LandedCostTran.invoiceDate> >, And <LandedCostTran.source, Equal <LandedCostTranSource.fromPO>, And <POReceipt.released, Equal <True>, And <LandedCostTran.processed, Equal <False> > > > > > > .Select(this, p.StartDate, p.EndDate); if (lcTranFromPO != null && lcTranFromPO.LCTranID.HasValue) { throw new PXException(Messages.PeriodHasINDocsFromPO_LCToBeCreated); } p.INClosed = true; Caches[typeof(FinPeriod)].Update(p); Actions.PressSave(); }