Exemplo n.º 1
0
        public void Update(Doc document)
        {
            if (document == null)
            {
                return;
            }
            RUTROT rutrot     = Rutrots.Current ?? Rutrots.SelectSingle();
            DocExt documentRR = PXCache <Doc> .GetExtension <DocExt>(document);

            Branch branch = PXSelect <Branch, Where <Branch.branchID, Equal <Required <Branch.branchID> > > > .Select(Base, documentRR.GetDocumentBranchID());

            BranchRUTROT branchRR   = RUTROTHelper.GetExtensionNullable <Branch, BranchRUTROT>(branch);
            PXErrorLevel errorLevel = documentRR.GetDocumentHold() != true ? PXErrorLevel.Error : PXErrorLevel.Warning;

            bool enableEdit         = documentRR.GetRUTROTCompleted() != true && RUTROTHelper.CurrenciesMatch(branchRR, documentRR) && document.DocType != ARDocType.CreditMemo;
            bool showSection        = documentRR.IsRUTROTDeductible == true;
            bool showROTSection     = showSection && rutrot?.RUTROTType == RUTROTTypes.ROT;
            bool isAutoDistribution = rutrot?.AutoDistribution == true;

            UpdateRUTROTCheckbox(enableEdit, RUTROTHelper.IsRUTROTAllowed(branchRR, documentRR));
            UpdateRUTROTSection(showSection, enableEdit, showROTSection);
            UpdateDistributionControls(showSection, enableEdit, isAutoDistribution);
            SetPersistingChecks(documentRR, rutrot);
            WarnOnDeductionExceedsAllowance(documentRR, rutrot, errorLevel);
            WarnUndistributedAmount(documentRR, rutrot, errorLevel, currencyinfo.Current ?? currencyinfo.SelectSingle());
        }
Exemplo n.º 2
0
        public void Prefetch()
        {
            var tempGraph = PXGraph.CreateInstance <PXGraph>();

            PXSelectBase <Table> select = CreateSelect(tempGraph);

            using (new PXFieldScope(select.View, typeof(KeyField)))
                RecordExists = ((Table)select.SelectSingle()) != null;
        }
        ///<summary>
        /// Finding inconsistency between GL module and document.
        /// Run this method at start point of the "Release" process.
        /// Validating case:
        /// Unreleased document shouldn't have GL Batch before/after the "Release" process.
        ///</summary>
        public DataIntegrityValidator <TRegister> CheckTransactionsExistenceForUnreleasedDocument(bool disableCheck = false)
        {
            if (IsSkipCheck(disableCheck))
            {
                return(this);
            }

            GLTran tran;

            if (_released != true &&
                (tran = _selectGLTran.SelectSingle(_module, _doc.DocType, _doc.RefNbr, _referenceID)) != null)
            {
                _errors.Add(new InconsistencyError <InconsistencyCode.unreleasedDocumentHasGlTransactions>(
                                new RecordContextInfo(_docCache, _doc),
                                new RecordContextInfo(_selectGLTran.Cache, tran)));
            }

            return(this);
        }
Exemplo n.º 4
0
        public static CurrencyInfo SelectCurrencyInfo(PXSelectBase <CurrencyInfo> currencyInfoView, long?curyInfoID)
        {
            if (curyInfoID == null)
            {
                return(null);
            }

            var result = (CurrencyInfo)currencyInfoView.Cache.Current;

            return(result != null && curyInfoID == result.CuryInfoID ? result : currencyInfoView.SelectSingle());
        }