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()); }
public void UncheckRUTROTIfProhibited(IRUTROTable document, Branch branch) { if (branch == null || document == null) { return; } BranchRUTROT branchRR = PXCache <Branch> .GetExtension <BranchRUTROT>(branch); if (RUTROTHelper.IsRUTROTAllowed(branchRR, document) == false && document.IsRUTROTDeductible == true) { document.IsRUTROTDeductible = false; Document.Cache.Update(document.GetBaseDocument()); } }