Beispiel #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);
            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());
        }
Beispiel #2
0
        protected virtual void ARInvoice_CuryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            var row = (ARInvoice)e.Row;

            if (row == null)
            {
                return;
            }

            ARInvoiceRUTROT doc = RUTROTHelper.GetExtensionNullable <ARInvoice, ARInvoiceRUTROT>(row);

            if (!RUTROTHelper.CurrenciesMatch(RUTROTHelper.GetBranchRUTROT(Base), doc))
            {
                doc.IsRUTROTDeductible = false;
            }
        }