Exemple #1
0
        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();
        }
Exemple #2
0
        protected override void ClosePeriodProc(FinPeriod p)
        {
            APRegister prebookedDoc = PXSelect <APRegister, Where <APRegister.voided, Equal <boolFalse>,
                                                                   And <APRegister.prebooked, Equal <boolTrue>,
                                                                        And <APRegister.released, Equal <boolFalse>,
                                                                             And <APRegister.finPeriodID, Equal <Required <APRegister.finPeriodID> > > > > > > .Select(this, p.FinPeriodID);

            if (prebookedDoc != null)
            {
                throw new PXException(Messages.PeriodHasPrebookedDocs);
            }

            PXSelectBase select = 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 <boolFalse>,
                                                           And <APRegister.scheduled, Equal <boolFalse>,
                                                                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);
            object doc = select.View.SelectSingle(p.FinPeriodID, p.FinPeriodID);

            if (doc != null)
            {
                throw new PXException(Messages.PeriodHasUnreleasedDocs);
            }

            PO.LandedCostTran lcTran = 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> > > > > > > > > .Select(this, p.StartDate, p.EndDate);

            if (lcTran != null && lcTran.LCTranID.HasValue)
            {
                throw new PXException(Messages.PeriodHasAPDocsFromPO_LCToBeCreated);
            }

            p.APClosed = true;
            Caches[typeof(FinPeriod)].Update(p);

            Actions.PressSave();
        }