protected virtual void GLAllocationDestination_RowPersisting(PXCache cache, PXRowPersistingEventArgs e) { GLAllocationDestination row = (GLAllocationDestination)e.Row; if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete) { VerifyAccountIDToBeNoControl <GLAllocationDestination.accountID, Account.accountID>(cache, e, row.AccountID, Allocation.Current?.AllocLedgerID); VerifyAccountIDToBeNoControl <GLAllocationDestination.basisAccountCD, Account.accountCD>(cache, e, row.BasisAccountCD, Allocation.Current?.AllocLedgerID); GLAllocation parent = this.Allocation.Current; List <GLAllocationDestination> duplicated = FindDuplicated(row, parent); //if (parent.AllocMethod == Constants.AllocationMethod.ByAcctPTD || parent.AllocMethod == Constants.AllocationMethod.ByAcctYTD) { if (duplicated.Count > 0) { duplicated.Add(row); foreach (GLAllocationDestination it in duplicated) { PXErrorLevel level = (parent.AllocMethod == Constants.AllocationMethod.ByAcctPTD || parent.AllocMethod == Constants.AllocationMethod.ByAcctYTD) ? PXErrorLevel.RowError : PXErrorLevel.RowWarning; string message = (parent.AllocMethod == Constants.AllocationMethod.ByAcctPTD || parent.AllocMethod == Constants.AllocationMethod.ByAcctYTD) ? Messages.ERR_AllocationDestinationAccountMustNotBeDuplicated : Messages.AllocationDestinationAccountAreIdentical; cache.RaiseExceptionHandling <GLAllocationDestination.accountID>(it, it.AccountID, new PXSetPropertyException(message, level)); } } } } }
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 static void RaiseException(this PXCache cache, string fieldName, object row, string message, object newValue = null, PXErrorLevel errorLevel = PXErrorLevel.Error) { var exception = new PXSetPropertyException(message, errorLevel); cache.RaiseExceptionHandling(fieldName, row, newValue, exception); }
public virtual void GLWorkBook_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { GLWorkBook row = (GLWorkBook)e.Row; if (row != null) { bool isSupported = IsSupported(row); if (!isSupported) { PXErrorLevel level = PXErrorLevel.Error; sender.RaiseExceptionHandling <GLWorkBook.docType>(row, row.DocType, new PXSetPropertyException(Messages.DocumentTypeIsNotSupportedYet, level)); } bool moduleAP = row.Module == BatchModule.AP; bool moduleAR = row.Module == BatchModule.AR; bool moduleCA = row.Module == BatchModule.CA; PXUIFieldAttribute.SetVisible <GLWorkBook.defaultVendorID>(sender, row, moduleAP); PXUIFieldAttribute.SetVisible <GLWorkBook.defaultCustomerID>(sender, row, moduleAR); PXUIFieldAttribute.SetVisible <GLWorkBook.defaultLocationID>(sender, row, moduleAP || moduleAR); PXUIFieldAttribute.SetVisible <GLWorkBook.defaultCashAccountID>(sender, row, moduleCA); PXUIFieldAttribute.SetVisible <GLWorkBook.defaultEntryTypeID>(sender, row, moduleCA); PXUIFieldAttribute.SetEnabled <GLWorkBook.defaultVendorID>(sender, row, moduleAP); PXUIFieldAttribute.SetEnabled <GLWorkBook.defaultCustomerID>(sender, row, moduleAR); PXUIFieldAttribute.SetEnabled <GLWorkBook.defaultLocationID>(sender, row, moduleAP || moduleAR); PXUIFieldAttribute.SetEnabled <GLWorkBook.defaultCashAccountID>(sender, row, moduleCA); PXUIFieldAttribute.SetEnabled <GLWorkBook.defaultEntryTypeID>(sender, row, moduleCA); bool haveBatches = batches.SelectSingle() != null; WorkBooks.Cache.AllowDelete = !haveBatches; PXUIFieldAttribute.SetEnabled <GLWorkBook.module>(sender, row, !haveBatches); PXUIFieldAttribute.SetEnabled <GLWorkBook.docType>(sender, row, !haveBatches); CheckNumbering(sender, row); } }
public PXUIVerifyAttribute(Type conditionType, PXErrorLevel errorLevel, string message, params Type[] args) : base(conditionType) { _ErrorLevel = errorLevel; _Message = message; _args = args; this.VerificationPoints = TriggerPoints.RowInserted | TriggerPoints.RowPersisting | TriggerPoints.FieldVerifying; }
public static void RaiseException <TField>(this PXCache cache, object row, string message, object newValue = null, PXErrorLevel errorLevel = PXErrorLevel.Error) where TField : IBqlField { var exception = new PXSetPropertyException(message, errorLevel); cache.RaiseExceptionHandling <TField>(row, newValue, exception); }
private static void RaiseExceptionForRelatedField <TField>(PXCache cache, object entity, string errorMessage, PXErrorLevel errorLevel) where TField : IBqlField { var exception = new PXSetPropertyException <TField>(errorMessage, errorLevel); cache.RaiseExceptionHandling <TField>(entity, cache.GetValue <TField>(entity), exception); }
protected PXFieldProcessingException(string fieldName, Exception inner, PXErrorLevel errorLevel, string format, params object[] args) : base(inner, errorLevel, format, args) { FieldName = fieldName; if (_Message != null && _Message.Length > 2 && _Message[_Message.Length - 1] == '.' && _Message[_Message.Length - 2] == '.' && _Message[_Message.Length - 3] != '.') { _Message = _Message.Substring(0, _Message.Length - 1); } }
public static bool IsHigherErrorLevelExist <T>(PXCache cache, object row, PXErrorLevel errorLevel) where T : IBqlField { PXFieldState state = (PXFieldState)cache.GetStateExt <T>(row); if (state.ErrorLevel > errorLevel) { return(true); } return(false); }
private bool WarnUndistributedAmount(IRUTROTable document, RUTROT rutrot, PXErrorLevel errorLevel, CurrencyInfo currencyInfo) { if (document == null || rutrot == null || document.IsRUTROTDeductible != true) { return(false); } decimal maxDiff = 0.0m; if (PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.invoiceRounding>() && currencyInfo != null) { var distributor = new DistributionRounding(ARSetup.Current, true) { CuryPlaces = currencyInfo.CuryPrecision ?? 0 }; maxDiff = distributor.FinishStep; } Action <string> setNotification = null; if (errorLevel == PXErrorLevel.Error) { setNotification = m => Rutrots.Cache.RaiseExceptionHandling <RUTROT.curyUndistributedAmt>(rutrot, rutrot.CuryUndistributedAmt, new PXSetPropertyException(m, errorLevel)); } else { setNotification = m => PXUIFieldAttribute.SetWarning <RUTROT.curyUndistributedAmt>(Rutrots.Cache, rutrot, m); } if (rutrot.CuryUndistributedAmt > maxDiff) { if (rutrot.AutoDistribution == true) { setNotification(RUTROTMessages.PositiveUndistributedAmount); return(true); } else { PXUIFieldAttribute.SetWarning <RUTROT.curyUndistributedAmt>(Rutrots.Cache, rutrot, RUTROTMessages.PositiveUndistributedAmount); return(false); } } else if (rutrot.CuryUndistributedAmt < 0.0m) { setNotification(RUTROTMessages.NegativeUndistributedAmount); return(true); } else { Rutrots.Cache.RaiseExceptionHandling <RUTROT.curyUndistributedAmt>(rutrot, rutrot.CuryUndistributedAmt, null); return(false); } }
/// <summary> /// This method validates if necessary fields are not null and launch the corresponding exception and error message. /// </summary> public virtual void LineTypeValidateLine(PXCache cache, FSServiceTemplateDet fsServiceTemplateDetRow, PXErrorLevel errorLevel = PXErrorLevel.Error) { switch (fsServiceTemplateDetRow.LineType) { case ID.LineType_ServiceTemplate.INVENTORY_ITEM: if (fsServiceTemplateDetRow.InventoryID == null) { cache.RaiseExceptionHandling <FSServiceTemplateDet.inventoryID>(fsServiceTemplateDetRow, null, new PXSetPropertyException(TX.Error.DATA_REQUIRED_FOR_LINE_TYPE, errorLevel)); } if (fsServiceTemplateDetRow.Qty < 0) { cache.RaiseExceptionHandling <FSServiceTemplateDet.qty>(fsServiceTemplateDetRow, null, new PXSetPropertyException(TX.Error.NEGATIVE_QTY, errorLevel)); } break; case ID.LineType_ServiceTemplate.COMMENT: case ID.LineType_ServiceTemplate.INSTRUCTION: if (string.IsNullOrEmpty(fsServiceTemplateDetRow.TranDesc)) { cache.RaiseExceptionHandling <FSServiceTemplateDet.tranDesc>(fsServiceTemplateDetRow, null, new PXSetPropertyException(TX.Error.DATA_REQUIRED_FOR_LINE_TYPE, errorLevel)); } break; case ID.LineType_ServiceTemplate.SERVICE: case ID.LineType_ServiceTemplate.NONSTOCKITEM: if (fsServiceTemplateDetRow.InventoryID == null) { cache.RaiseExceptionHandling <FSServiceTemplateDet.inventoryID>(fsServiceTemplateDetRow, null, new PXSetPropertyException(TX.Error.DATA_REQUIRED_FOR_LINE_TYPE, errorLevel)); } if (fsServiceTemplateDetRow.Qty < 0) { cache.RaiseExceptionHandling <FSServiceTemplateDet.qty>(fsServiceTemplateDetRow, null, new PXSetPropertyException(TX.Error.NEGATIVE_QTY, errorLevel)); } break; } }
private void ValidateInventoryItem(POLine subcontractLine, PXErrorLevel errorLevel) { if (!IsInventoryItemValid(subcontractLine)) { var inventoryItem = GetInventoryItem(subcontractLine.InventoryID); Transactions.Cache.RaiseException <POLine.inventoryID>(subcontractLine, ScMessages.ItemIsNotPresentedInTheProjectBudget, inventoryItem.InventoryCD, errorLevel); } else { Transactions.Cache.ClearFieldErrors <POLine.inventoryID>(subcontractLine); } }
private static void RaiseOrClearExceptionForRelatedField <TField>( PXCache cache, object entity, bool validationErrorNeeded, PXErrorLevel errorLevel) where TField : IBqlField { if (validationErrorNeeded) { RaiseCorrectExceptionForRelatedField <TField>( cache, entity, ComplianceMessages.ExpiredComplianceMessage, errorLevel); } else { cache.ClearFieldErrorIfExists <TField>(entity, ComplianceMessages.ExpiredComplianceMessage); } }
public void ValidateJointPayee(PXCache cache, JointPayee jointPayee, List <int?> projectIds, string message, PXErrorLevel errorLevel = PXErrorLevel.Warning) { if (jointPayee.JointPayeeExternalName == null || jointPayee.JointPayeeInternalId == null) { var doesAnyOutstandingComplianceExist = lienWaiverDataProvider .DoesAnyOutstandingComplianceExistForJointVendor(jointPayee.JointPayeeInternalId, projectIds); SetWarningIfNeeded <JointPayee.jointPayeeInternalId>(cache, jointPayee, message, doesAnyOutstandingComplianceExist, errorLevel); doesAnyOutstandingComplianceExist = lienWaiverDataProvider .DoesAnyOutstandingComplianceExistForJointVendor(jointPayee.JointPayeeExternalName, projectIds); SetWarningIfNeeded <JointPayee.jointPayeeExternalName>(cache, jointPayee, message, doesAnyOutstandingComplianceExist, errorLevel); } }
public static void DisplayFieldError <TField>( this PXCache cache, object record, PXErrorLevel errorLevel, string message, params object[] errorMessageArguments) where TField : IBqlField { PXSetPropertyException <TField> setPropertyException = new PXSetPropertyException <TField>(message, errorLevel, errorMessageArguments); if (cache.RaiseExceptionHandling <TField>(record, null, setPropertyException)) { throw setPropertyException; } }
public virtual void GLTranCode_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { if (e.Row != null) { GLTranCode row = (GLTranCode)e.Row; bool isSupported = IsSupported(row); if (!isSupported) { PXErrorLevel level = (row.Active == true) ? PXErrorLevel.Error : PXErrorLevel.Warning; sender.RaiseExceptionHandling <GLTranCode.tranType>(row, row.TranType, new PXSetPropertyException(Messages.DocumentTypeIsNotSupportedYet, level)); } else { sender.RaiseExceptionHandling <GLTranCode.tranType>(row, row.TranType, null); } } }
public virtual void POOrderRS_CuryID_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { POOrderRS row = (POOrderRS)e.Row; APInvoice doc = Base.Document.Current; if (row != null && doc != null) { if (row.CuryID != doc.CuryID) { string fieldName = typeof(POOrderRS.curyID).Name; PXErrorLevel msgLevel = PXErrorLevel.RowWarning; e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(String), false, null, null, null, null, null, fieldName, null, null, AP.Messages.APDocumentCurrencyDiffersFromSourceDocument, msgLevel, null, null, null, PXUIVisibility.Undefined, null, null, null); e.IsAltered = true; } } }
protected virtual void RUTROT_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { RUTROT rutrot = (RUTROT)e.Row; DocExt doc = RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current); bool treatAsError = doc?.GetDocumentHold() != true; PXErrorLevel errorLevel = treatAsError ? PXErrorLevel.Error : PXErrorLevel.Warning; if (WarnOnDeductionExceedsAllowance(doc, rutrot, errorLevel) && treatAsError) { throw new PXSetPropertyException(Rutrots.Current.CuryAllowedAmt == 0.0m ? RUTROTMessages.PeopleAreRequiredForDeduction : RUTROTMessages.DeductibleExceedsAllowance, PXErrorLevel.Error); } if (WarnUndistributedAmount(doc, rutrot, errorLevel, currencyinfo.Current ?? currencyinfo.SelectSingle()) && treatAsError) { throw new PXSetPropertyException(RUTROTMessages.UndistributedAmount, PXErrorLevel.Error); } }
public virtual void POReceiptLineS_ReceiptNbr_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { POReceiptLineS row = (POReceiptLineS)e.Row; APInvoice doc = Base.Document.Current; if (row != null && doc != null) { POOrder order = PXSelect <POOrder, Where <POOrder.orderType, Equal <Required <POOrder.orderType> >, And <POOrder.orderNbr, Equal <Required <POOrder.orderNbr> > > > > .Select(Base, row.POType, row.PONbr); if (order != null && order.CuryID != doc.CuryID) { string fieldName = typeof(POReceipt.curyID).Name; PXErrorLevel msgLevel = PXErrorLevel.RowWarning; e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(String), false, null, null, null, null, null, fieldName, null, null, AP.Messages.APDocumentCurrencyDiffersFromSourceDocument, msgLevel, null, null, null, PXUIVisibility.Undefined, null, null, null); e.IsAltered = true; } } }
protected virtual void RUTROT_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { RUTROT rutrot = (RUTROT)e.Row; DocExt doc = RUTROTHelper.GetExtensionNullable <Doc, DocExt>(Document.Current); bool treatAsError = doc?.GetDocumentHold() != true; PXErrorLevel errorLevel = treatAsError ? PXErrorLevel.Error : PXErrorLevel.Warning; if (WarnOnDeductionExceedsAllowance(doc, rutrot, errorLevel) && treatAsError) { sender.RaiseExceptionHandling <RUTROT.curyTotalAmt>(rutrot, rutrot.CuryTotalAmt, new PXSetPropertyException(rutrot.CuryAllowedAmt == 0.0m ? RUTROTMessages.PeopleAreRequiredForDeduction : RUTROTMessages.DeductibleExceedsAllowance, PXErrorLevel.Error)); } if (WarnUndistributedAmount(doc, rutrot, errorLevel, currencyinfo.Current ?? currencyinfo.SelectSingle()) && treatAsError) { sender.RaiseExceptionHandling <RUTROT.curyTotalAmt>(rutrot, rutrot.CuryTotalAmt, new PXSetPropertyException(RUTROTMessages.UndistributedAmount, PXErrorLevel.Error)); } if (doc != null && doc.IsRUTROTDeductible == true) { foreach (Tran tran in Transactions.Select()) { TranExt tranRR = RUTROTHelper.GetExtensionNullable <Tran, TranExt>(tran); if (tranRR.GetInventoryID() != null) { InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, tranRR.GetInventoryID()); InventoryItemRUTROT itemRR = PXCache <InventoryItem> .GetExtension <InventoryItemRUTROT>(item); if (!RUTROTHelper.IsItemMatchRUTROTType(rutrot.RUTROTType, item, itemRR, itemRR?.IsRUTROTDeductible == true)) { var exception = new PXSetPropertyException(RUTROTMessages.LineDoesNotMatchDoc, PXErrorLevel.RowError); Transactions.Cache.RaiseExceptionHandling(RUTROTHelper.IsRUTROTDeductible, tran, tranRR.IsRUTROTDeductible, exception); throw exception; } } } } }
private void WarnPersonAmount(RUTROTDistribution personalAmount, RUTROT rutrot, IRUTROTable document) { if (document == null || rutrot == null || document.IsRUTROTDeductible != true || personalAmount == null) { return; } bool treatAsError = document.GetDocumentHold() != true; PXErrorLevel errorLevel = treatAsError ? PXErrorLevel.Error : PXErrorLevel.Warning; PXSetPropertyException <RUTROTDistribution.curyAmount> error = null; if (personalAmount.CuryAmount < 0.0m && rutrot.CuryTotalAmt != 0.0m) { error = new PXSetPropertyException <RUTROTDistribution.curyAmount>(RUTROTMessages.NonpositivePersonAmount, errorLevel); } else if (personalAmount.CuryAmount > personalAmount.CuryAllowance) { error = new PXSetPropertyException <RUTROTDistribution.curyAmount>(RUTROTMessages.PersonExceedsAllowance, PXErrorLevel.Error); } RRDistribution.Cache.RaiseExceptionHandling <RUTROTDistribution.curyAmount>(personalAmount, personalAmount.CuryAmount, error); }
public virtual void POReceipt_ReceiptNbr_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e) { POReceipt row = (POReceipt)e.Row; APInvoice doc = Base.Document.Current; if (row != null && doc != null) { PXResultset <POOrderReceiptLink> receiptLinks = PXSelectGroupBy <POOrderReceiptLink, Where <POOrderReceiptLink.receiptNbr, Equal <Required <POReceipt.receiptNbr> > >, Aggregate <GroupBy <POOrderReceiptLink.curyID> > > .Select(Base, row.ReceiptNbr); if (receiptLinks.Count == 0) { return; } else if (receiptLinks.Count > 1 || ((POOrderReceiptLink)receiptLinks.First()).CuryID != doc.CuryID) { string fieldName = typeof(POReceipt.curyID).Name; PXErrorLevel msgLevel = PXErrorLevel.RowWarning; e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, typeof(String), false, null, null, null, null, null, fieldName, null, null, AP.Messages.APDocumentCurrencyDiffersFromSourcePODocument, msgLevel, null, null, null, PXUIVisibility.Undefined, null, null, null); e.IsAltered = true; } } }
public override void AddMessage(PXErrorLevel errorLevel, string message) { _messages.Add(new ProcessingResultMessage(errorLevel, PXMessages.LocalizeNoPrefix(message))); }
public ProcessingResultMessage(PXErrorLevel errorLevel, string text) { Text = text; ErrorLevel = errorLevel; }
public override void AddMessage(PXErrorLevel errorLevel, string message, params object[] args) { _messages.Add(new ProcessingResultMessage(errorLevel, PXMessages.LocalizeFormatNoPrefix(message, args))); }
public abstract void AddMessage(PXErrorLevel errorLevel, string message);
public abstract void AddMessage(PXErrorLevel errorLevel, string message, params object[] args);
public static void RaiseOrHideError <T>(PXCache cache, object row, bool isIncorrect, string message, PXErrorLevel errorLevel, params object[] parameters) where T : IBqlField { if (isIncorrect) { cache.RaiseExceptionHandling <T>(row, cache.GetValue <T>(row), new PXSetPropertyException(message, errorLevel, parameters)); } else { cache.RaiseExceptionHandling <T>(row, cache.GetValue <T>(row), null); } }
public PXUIVerifyAttribute(Type conditionType, TriggerPoints verificationPoints, PXErrorLevel errorLevel, string message, params Type[] args) : this(conditionType, errorLevel, message, args) { this.VerificationPoints = verificationPoints; }
public PXUIVerifyAttribute(Type conditionType, PXErrorLevel errorLevel, string message, bool OnSelectingVerify, params Type[] args) : this(conditionType, errorLevel, message, args) { this.CheckOnRowSelected = OnSelectingVerify; }
public PXSetPropertyKeepPreviousException(string format, PXErrorLevel errorLevel, params object[] args) : base(format, errorLevel, args) { }
public PXSetPropertyKeepPreviousException(Exception inner, PXErrorLevel errorLevel, string format, params object[] args) : base(inner, errorLevel, format, args) { }
public PXFieldValueProcessingException(string fieldName, Exception inner, PXErrorLevel errorLevel, params object[] args) : base(fieldName, inner, errorLevel, ErrorMessages.ErrorFieldValueProcessing, args) { }
protected PXFieldProcessingException(string fieldName, Exception inner, PXErrorLevel errorLevel, string format, params object[] args) : base(inner, errorLevel, format, args) { FieldName = fieldName; }
public PXSetPropertyKeepPreviousException(string message, PXErrorLevel errorLevel) : base(message, errorLevel) { }
public PXSetPropertyException(string message, PXErrorLevel errorLevel) : this(message) { this._ErrorLevel = errorLevel; }
public PXSetPropertyException(Exception inner, PXErrorLevel errorLevel, string format, params object[] args) : base(inner, format, args) { this._ErrorLevel = errorLevel; }