/// <summary> /// Method build sales or expense sub account by mask for receipt /// </summary> /// <typeparam name="SubMaskField"><see=EPSetup.salesSubMask/> or <see=EPSetup.expenseSubMask/></typeparam> /// <typeparam name="CompanySubField">Field of receipt with company sub account (<see=Location.cMPSalesSubID/> or <see=Location.cMPExpenseSubID/>)</typeparam> /// <typeparam name="EmployeeSubField">Field of receipt with employee sub account (<see=EPEmployee.salesSubID/> or <see=EPEmployee.expenseSubID/>)</typeparam> /// <typeparam name="ItemSubField">Field of receipt with inventory item sub account (<see=InventoryItem.salesSubID/> or <see=InventoryItem.cOGSSubID/>)</typeparam> /// <param name="receiptCache">Cache of receipt</param> /// <param name="receipt">Receipt for which build sub account</param> /// <param name="subMask">Mask from <see=EPSetup/></param> /// <returns>Sub account by mask</returns> public static object MakeSubAccountByMaskForReceipt <SubMaskField, CompanySubField, EmployeeSubField, ItemSubField>(PXCache receiptCache, EPExpenseClaimDetails receipt, string subMask) where SubMaskField : IBqlField where CompanySubField : IBqlField where EmployeeSubField : IBqlField where ItemSubField : IBqlField { object value = null; InventoryItem item = (InventoryItem)PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(receiptCache.Graph, receipt.InventoryID); Location companyloc = (Location)PXSelectJoin <Location, InnerJoin <BAccountR, On <Location.bAccountID, Equal <BAccountR.bAccountID>, And <Location.locationID, Equal <BAccountR.defLocationID> > >, InnerJoin <GL.Branch, On <BAccountR.bAccountID, Equal <GL.Branch.bAccountID> > > >, Where <GL.Branch.branchID, Equal <Current <EPExpenseClaimDetails.branchID> > > > .Select(receiptCache.Graph, receipt); Contract contract = PXSelect <Contract, Where <Contract.contractID, Equal <Required <Contract.contractID> > > > .Select(receiptCache.Graph, receipt.ContractID); PMTask task = PXSelect <PMTask, Where <PMTask.projectID, Equal <Required <PMTask.projectID> >, And <PMTask.taskID, Equal <Required <PMTask.taskID> > > > > .Select(receiptCache.Graph, receipt.ContractID, receipt.TaskID); Location customerLocation = (Location)PXSelectorAttribute.Select <EPExpenseClaimDetails.customerLocationID>(receiptCache, receipt); EPEmployee employee = (EPEmployee)PXSelect <EPEmployee> .Search <EPEmployee.bAccountID>(receiptCache.Graph, receipt != null?receipt.EmployeeID : null); int?employee_SubID = (int?)receiptCache.Graph.Caches[typeof(EPEmployee)].GetValue <EmployeeSubField>(employee); int?item_SubID = (int?)receiptCache.Graph.Caches[typeof(InventoryItem)].GetValue <ItemSubField>(item); int?company_SubID = (int?)receiptCache.Graph.Caches[typeof(Location)].GetValue <CompanySubField>(companyloc); int?project_SubID = (int?)receiptCache.Graph.Caches[typeof(Contract)].GetValue <Contract.defaultSubID>(contract); int?task_SubID = (int?)receiptCache.Graph.Caches[typeof(PMTask)].GetValue <PMTask.defaultSubID>(task); int?location_SubID = (int?)receiptCache.Graph.Caches[typeof(Location)].GetValue <Location.cSalesSubID>(customerLocation); value = SubAccountMaskAttribute.MakeSub <SubMaskField>(receiptCache.Graph, subMask, new object[] { employee_SubID, item_SubID, company_SubID, project_SubID, task_SubID, location_SubID }, new Type[] { typeof(EmployeeSubField), typeof(ItemSubField), typeof(CompanySubField), typeof(Contract.defaultSubID), typeof(PMTask.defaultSubID), typeof(Location.cSalesSubID) }); return(value); }
protected virtual void XRBGLDist_UsrDiscountReasonID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { XRBGLDist row = (XRBGLDist)e.Row; if (row != null) { if (!(row.DiscPct > (decimal?)0.0)) { PXCache hCache = Base.Distributions.Cache; XRBGLDist hdr = Base.Distributions.Current; CAMPDiscountReasonCode rc = (CAMPDiscountReasonCode)PXSelectorAttribute.Select <XRBGLDistExt.usrDiscountReasonID>(hCache, hdr); if (rc != null) { row.DiscPct = rc.DefaultPct; } } } }
protected virtual void CABatch_CashAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CABatch row = (CABatch)e.Row; row.Cleared = false; row.ClearDate = null; if (cashAccount.Current == null || cashAccount.Current.CashAccountID != row.CashAccountID) { cashAccount.Current = (CashAccount)PXSelectorAttribute.Select <CABatch.cashAccountID>(sender, row); } if (cashAccount.Current.Reconcile != true) { row.Cleared = true; row.ClearDate = row.TranDate; } sender.SetDefaultExt <CABatch.referenceID>(e.Row); sender.SetDefaultExt <CABatch.paymentMethodID>(e.Row); }
protected virtual void Customer_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { if (e.Row != null) { Customer cust = PXSelectorAttribute.Select <Customer.acctCD>(sender, e.Row) as Customer; if (cust != null) { cust.Included = true; PXCache <Customer> .RestoreCopy((Customer)e.Row, cust); sender.SetStatus(e.Row, PXEntryStatus.Updated); } else { sender.Delete(e.Row); } } }
protected virtual void InventoryItem_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { if (e.Row != null) { InventoryItem item = PXSelectorAttribute.Select <InventoryItem.inventoryCD>(sender, e.Row) as InventoryItem; if (item != null) { item.Included = true; PXCache <InventoryItem> .RestoreCopy((InventoryItem)e.Row, item); sender.SetStatus(e.Row, PXEntryStatus.Updated); } else { sender.Delete(e.Row); } } }
protected virtual void Vendor_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { if (e.Row != null) { Vendor vend = PXSelectorAttribute.Select <Vendor.acctCD>(sender, e.Row) as Vendor; if (vend != null) { vend.Included = true; PXCache <Vendor> .RestoreCopy((Vendor)e.Row, vend); sender.SetStatus(e.Row, PXEntryStatus.Updated); } else { sender.Delete(e.Row); } } }
protected virtual void Contact_ClassID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { Contact row = (Contact)e.Row; CRContactClass cc = (CRContactClass)PXSelectorAttribute.Select <Contact.classID>(sender, row, e.NewValue); this.doCopyClassSettings = false; if (cc != null) { this.doCopyClassSettings = true; if (sender.GetStatus(row) != PXEntryStatus.Inserted) { if (e.ExternalCall && Lead.Ask(Messages.Warning, Messages.ContactClassChangeWarning, MessageButtons.YesNo) == WebDialogResult.No) { this.doCopyClassSettings = false; } } } }
private void ValidateUniqueness(PXCache sender, ContractDetail row, System.ComponentModel.CancelEventArgs e) { if (row.ContractItemID.HasValue) { PXSelectBase <ContractDetail> s = new PXSelect <ContractDetail, Where <ContractDetail.contractItemID, Equal <Required <ContractDetail.contractItemID> >, And <ContractDetail.contractID, Equal <Current <ContractTemplate.contractID> >, And <ContractDetail.contractDetailID, NotEqual <Required <ContractDetail.contractDetailID> > > > > >(this); ContractDetail item = s.SelectWindowed(0, 1, row.ContractItemID, row.ContractDetailID); if (item != null) { ContractItem cirow = (ContractItem)PXSelectorAttribute.Select <ContractDetail.contractItemID>(sender, row); sender.RaiseExceptionHandling <ContractDetail.contractItemID>(row, cirow.ContractItemCD, new PXException(Messages.ItemNotUnique)); e.Cancel = true; } } }
protected virtual void FixedAsset_UsefulLife_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { FixedAsset header = (FixedAsset)e.Row; if (header == null) return; foreach (FABookSettings newSettings in PXSelect<FABookSettings, Where<FABookSettings.assetID, Equal<Required<FABookSettings.assetID>>>>.Select(this, header.AssetID) .RowCast<FABookSettings>() .Select(set => (FABookSettings)DepreciationSettings.Cache.CreateCopy(set))) { FADepreciationMethod deprMethod = PXSelectorAttribute.Select<FABookSettings.depreciationMethodID>(DepreciationSettings.Cache, newSettings) as FADepreciationMethod; if (deprMethod?.DepreciationMethod != FADepreciationMethod.depreciationMethod.AustralianPrimeCost && deprMethod?.DepreciationMethod != FADepreciationMethod.depreciationMethod.NewZealandStraightLine && deprMethod?.DepreciationMethod != FADepreciationMethod.depreciationMethod.NewZealandStraightLineEvenly) { newSettings.UsefulLife = header.UsefulLife; DepreciationSettings.Update(newSettings); } } }
protected virtual void CABankTranRule_BankTranCashAccountID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { var rule = e.Row as CABankTranRule; if (rule == null) { return; } if (rule.BankTranCashAccountID != null) { var cashAcct = (CashAccount)PXSelectorAttribute.Select <CABankTranRule.bankTranCashAccountID>(cache, rule); cache.SetValueExt <CABankTranRule.tranCuryID>(rule, cashAcct.CuryID); } else { cache.SetDefaultExt <CABankTranRule.tranCuryID>(rule); } }
protected virtual void BatchSelection_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e) { Batch b = e.Row as Batch; if (b != null && b.Voided == false) { b.Scheduled = true; b.ScheduleID = Schedule_Header.Current.ScheduleID; } BatchSelection batch = e.Row as BatchSelection; if (batch != null && !string.IsNullOrWhiteSpace(batch.Module) && !string.IsNullOrWhiteSpace(batch.BatchNbr) && PXSelectorAttribute.Select <BatchSelection.batchNbr>(cache, batch) == null) { cache.RaiseExceptionHandling <BatchSelection.batchNbr>(batch, batch.BatchNbr, new PXSetPropertyException(Messages.BatchNbrNotValid)); Batch_Detail.Cache.Remove(batch); } }
protected virtual void INLocation_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { INLocation row = e.Row as INLocation; if (row == null) { return; } if (row.PrimaryItemID != null && PXSelectorAttribute.Select <INLocation.primaryItemID>(sender, row) == null) { PXUIFieldAttribute.SetWarning <INLocation.primaryItemID>(sender, row, Messages.ItemWasDeleted); } PXUIFieldAttribute.SetEnabled <INLocation.isCosted>(sender, row, row.ProjectID == null); bool warn = ShowWarningProjectLowestPickPriority(row); PXUIFieldAttribute.SetWarning <INLocation.pickPriority>(sender, row, warn ? Messages.LocationWithProjectLowestPickPriority : null); }
protected virtual void Customer_CustomerClassID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e) { Customer customerRow = (Customer)e.Row; CustomerClass customerClassRow = (CustomerClass)PXSelectorAttribute.Select <Customer.customerClassID>(cache, customerRow, e.NewValue); this.doCopyBillingSettings = false; if (customerClassRow != null) { this.doCopyBillingSettings = true; if (cache.GetStatus(customerRow) != PXEntryStatus.Inserted) { if (Base.CurrentCustomer.Ask(TX.WebDialogTitles.UPDATE_BILLING_SETTINGS, TX.Warning.CUSTOMER_CLASS_BILLING_SETTINGS, MessageButtons.YesNo) == WebDialogResult.No) { this.doCopyBillingSettings = false; } } } }
protected virtual void Account_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { Account row = (Account)e.Row; try { ValidateAccountGroupID(sender, row); } catch (PXSetPropertyException ex) { if (ex.ErrorLevel == PXErrorLevel.Error) { PM.PMAccountGroup item = (PM.PMAccountGroup)PXSelectorAttribute.Select <Account.accountGroupID>(sender, row); sender.RaiseExceptionHandling <Account.accountGroupID>(row, item.GroupCD, ex); throw ex; } } if (!string.IsNullOrEmpty(row.CuryID)) { CASetup casetup = PXSelect <CASetup> .Select(this); if (casetup != null && casetup.TransitAcctId != null && casetup.TransitAcctId == row.AccountID) { PXException exception = new PXException(CA.Messages.CashInTransitAccountCanNotBeDenominated); sender.RaiseExceptionHandling <Account.curyID>(row, row.CuryID, exception); throw exception; } string newCuryid; if (e.Operation == PXDBOperation.Update) { newCuryid = row.CuryID; byte[] timestamp = PXDatabase.SelectTimeStamp(); PXDatabase.Update <GLHistory>(new PXDataFieldAssign("CuryID", newCuryid), new PXDataFieldRestrict("AccountID", ((Account)e.Row).AccountID), new PXDataFieldRestrict("CuryID", PXDbType.VarChar, 5, null, PXComp.ISNULL), new PXDataFieldRestrict("tstamp", PXDbType.Timestamp, 8, timestamp, PXComp.LE)); } } }
protected virtual void APInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { APInvoice doc = (APInvoice)e.Row; Terms terms = (Terms)PXSelectorAttribute.Select <APInvoice.termsID>(Base.Document.Cache, doc); if (terms != null && doc.RetainageApply == true && terms.InstallmentType == CS.TermsInstallmentType.Multiple) { sender.RaiseExceptionHandling <APInvoice.termsID>(doc, doc.TermsID, new PXSetPropertyException(Messages.RetainageWithMultipleCreditTerms)); } bool disablePersistingCheckForRetainageAccountAndSub = doc.RetainageApply != true; PXDefaultAttribute.SetPersistingCheck <APRegister.retainageAcctID>(sender, doc, disablePersistingCheckForRetainageAccountAndSub ? PXPersistingCheck.Nothing : PXPersistingCheck.NullOrBlank); PXDefaultAttribute.SetPersistingCheck <APInvoice.retainageSubID>(sender, doc, disablePersistingCheckForRetainageAccountAndSub ? PXPersistingCheck.Nothing : PXPersistingCheck.NullOrBlank); }
protected virtual void DocTransaction_ProductID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { DocTransaction line = (DocTransaction)e.Row; Product product = null; SupplierProduct supplierData = null; if (line.ProductID != null) { product = PXSelectorAttribute.Select <DocTransaction.productID>(sender, line) as Product; if (product != null) { line.Description = product.ProductName; line.StockUnit = product.StockUnit; supplierData = PXSelect <SupplierProduct, Where <SupplierProduct.supplierID, Equal <Current <Document.supplierID> >, And <SupplierProduct.productID, Equal <Required <Product.productID> > > > > .Select(this, product.ProductID); if (supplierData != null) { line.Unit = supplierData.SupplierUnit; line.ConversionFactor = supplierData.ConversionFactor; line.UnitPrice = supplierData.SupplierPrice; } } } if (product == null) { sender.SetDefaultExt <DocTransaction.tranQty>(line); line.Description = null; line.StockUnit = null; } if (supplierData == null) { line.Unit = null; sender.SetDefaultExt <DocTransaction.conversionFactor>(line); line.UnitPrice = null; } }
protected virtual void ARTran_DiscPct_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e, PXFieldVerifying del) { ARTran row = (ARTran)e.Row; // Event handler body before the base BLC event handler collection if (row != null) { ARTranExt distEx = PXCache <ARTran> .GetExtension <ARTranExt>(row); if (distEx != null && distEx.UsrDiscountReasonID > 0) { PXCache hCache = Base.Transactions.Cache; ARTran hdr = Base.Transactions.Current; CAMPDiscountReasonCode rc = (CAMPDiscountReasonCode)PXSelectorAttribute.Select <ARTranExt.usrDiscountReasonID>(hCache, hdr); if (rc != null) { if ((bool)rc.AllowChanges) { if ((bool)rc.AllowChanges && !(bool)rc.AllowOverMax) { if ((decimal)e.NewValue > rc.MaxPct) { throw new PXSetPropertyException <ARTran.discPct>( "discount % greater then allowed Max % for discount reason code.", PXErrorLevel.Error); } } } else { throw new PXSetPropertyException <ARTran.discPct>( "Cannot make changes to discount %", PXErrorLevel.Error); } } } } // Event handler body after the base BLC event handler collection if (del != null) { del(sender, e); } }
private static void AddInvoicedBase(PXCache sender, PMCommitment container) { PMCommitment commitment = (PMCommitment)sender.Graph.Caches[typeof(PMCommitment)].Locate(container); if (commitment == null) { commitment = PXSelect <PMCommitment, Where <PMCommitment.commitmentID, Equal <Required <PMCommitment.commitmentID> > > > .Select(sender.Graph, container.CommitmentID); } if (commitment != null) { decimal quantity = container.InvoicedQty.GetValueOrDefault(); if (commitment.UOM != container.UOM) { if (PXAccess.FeatureInstalled <FeaturesSet.multipleUnitMeasure>()) { decimal inBase = IN.INUnitAttribute.ConvertToBase(sender.Graph.Caches[typeof(PMCommitment)], commitment.InventoryID, container.UOM, quantity, IN.INPrecision.QUANTITY); try { quantity = IN.INUnitAttribute.ConvertFromBase(sender.Graph.Caches[typeof(PMCommitment)], commitment.InventoryID, commitment.UOM, inBase, IN.INPrecision.QUANTITY); } catch (PX.Objects.IN.PXUnitConversionException ex) { IN.InventoryItem item = PXSelectorAttribute.Select(sender.Graph.Caches[typeof(PMCommitment)], commitment, "inventoryID") as IN.InventoryItem; string msg = PXMessages.LocalizeFormatNoPrefixNLA(Messages.UnitConversionNotDefinedForItemOnBudgetUpdate, item?.BaseUnit, commitment.UOM, item?.InventoryCD); throw new PXException(msg, ex); } } else { quantity = IN.INUnitAttribute.ConvertGlobalUnits(sender.Graph, container.UOM, commitment.UOM, quantity, IN.INPrecision.QUANTITY); } } commitment.InvoicedAmount += container.InvoicedAmount.GetValueOrDefault(); commitment.InvoicedQty += quantity; sender.Graph.Caches[typeof(PMCommitment)].Update(commitment); } }
public virtual int?GetProjectedAccountGroup(ARTran line) { int?projectedRevenueAccountGroupID = null; int?projectedRevenueAccount = line.AccountID; if (line.AccountID != null) { Account revenueAccount = PXSelectorAttribute.Select <ARTran.accountID>(Base.Transactions.Cache, line, line.AccountID) as Account; if (revenueAccount != null) { if (revenueAccount.AccountGroupID == null) { throw new PXException(PM.Messages.RevenueAccountIsNotMappedToAccountGroup, revenueAccount.AccountCD); } projectedRevenueAccountGroupID = revenueAccount.AccountGroupID; } } return(projectedRevenueAccountGroupID); }
protected virtual void INComponent_ComponentID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { INComponent row = e.Row as INComponent; if (row != null) { InventoryItem item = InventoryItem.PK.FindDirty(this, row.ComponentID); var deferralCode = (DRDeferredCode)PXSelectorAttribute.Select <InventoryItem.deferredCode>(Item.Cache, item); bool useDeferralFromItem = deferralCode != null && deferralCode.MultiDeliverableArrangement != true; if (item != null) { row.SalesAcctID = item.SalesAcctID; row.SalesSubID = item.SalesSubID; row.UOM = item.SalesUnit; row.DeferredCode = useDeferralFromItem ? item.DeferredCode : null; row.DefaultTerm = item.DefaultTerm; row.DefaultTermUOM = item.DefaultTermUOM; } } }
protected virtual void EPExpenseClaimDetails_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { EPExpenseClaimDetails row = e.Row as EPExpenseClaimDetails; InventoryItem item = PXSelectorAttribute.Select <InventoryItem.inventoryID>(cache, row) as InventoryItem; decimal curyStdCost; if (item != null && currencyinfo.Current != null && currencyinfo.Current.CuryRate != null) { PXCurrencyAttribute.CuryConvCury <EPExpenseClaimDetails.curyInfoID>(cache, e.Row, item.StdCost.Value, out curyStdCost, true); } else { curyStdCost = 0m; } cache.SetValueExt <EPExpenseClaimDetails.curyUnitCost>(row, curyStdCost); if (item != null && (epsetup.Current.AllowMixedTaxSettingInClaims == true || CurrentClaimDetails.Current.RefNbr == null)) { cache.SetValueExt <EPExpenseClaimDetails.taxCalcMode>(row, item.TaxCalcMode); } }
protected void CustomerPaymentMethodDetail_Insert(PXGraph graph, EntityImpl entity, EntityImpl targetEntity) { var maint = (CustomerPaymentMethodMaint)graph; var name = (EntityValueField)targetEntity.Fields.SingleOrDefault(f => f.Name.OrdinalEquals("Name")); var description = (EntityValueField)targetEntity.Fields.SingleOrDefault(f => f.Name.OrdinalEquals("Description")); var value = (EntityValueField)targetEntity.Fields.Single(f => f.Name.OrdinalEquals("Value")); var cache = maint.Details.Cache; foreach (CustomerPaymentMethodDetail detail in maint.Details.Select()) { var selectorRow = PXSelectorAttribute.Select(cache, detail, "DetailID") as PaymentMethodDetail; if ((name != null && (selectorRow.Descr == name.Value || detail.DetailID == name.Value)) || (description != null && (selectorRow.Descr == description.Value || selectorRow.DetailID == description.Value))) { cache.SetValueExt(detail, "Value", value.Value); maint.Details.Update(detail); break; } } }
public virtual IEnumerable InventorySummary(PXAdapter adapter) { PXCache tCache = transactions.Cache; INTran line = transactions.Current; if (line == null) { return(adapter.Get()); } InventoryItem item = (InventoryItem)PXSelectorAttribute.Select <INTran.inventoryID>(tCache, line); if (item != null && item.StkItem == true) { INSubItem sbitem = (INSubItem)PXSelectorAttribute.Select <INTran.subItemID>(tCache, line); InventorySummaryEnq.Redirect(item.InventoryID, ((sbitem != null) ? sbitem.SubItemCD : null), line.SiteID, line.LocationID); } return(adapter.Get()); }
protected virtual void CATransfer_InAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CATransfer transfer = e.Row as CATransfer; if (transfer.InAccountID == null) { return; } CashAccount cashaccountIn = (CashAccount)PXSelectorAttribute.Select <CATransfer.inAccountID>(sender, transfer); if (cashaccountIn?.Reconcile != true) { transfer.ClearedIn = true; transfer.ClearDateIn = transfer.InDate; } else { transfer.ClearedIn = false; transfer.ClearDateIn = null; } }
private int?GetAccountGroup(POLine subcontractLine, int?inventoryID) { InventoryItem item = GetInventoryItem(inventoryID); if (item.StkItem == true && item.COGSAcctID != null) { Account account = (Account)PXSelectorAttribute.Select <InventoryItem.cOGSAcctID>(Caches[typeof(InventoryItem)], item); if (account != null && account.AccountGroupID != null) { return(account.AccountGroupID); } } else { Account account = (Account)PXSelectorAttribute.Select <POLine.expenseAcctID>(Transactions.Cache, subcontractLine); if (account != null && account.AccountGroupID != null) { return(account.AccountGroupID); } } return(null); }
protected virtual void DocumentSelection_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e) { APRegister documentAsRegister = e.Row as APRegister; if (documentAsRegister != null && documentAsRegister.Voided == false) { documentAsRegister.ScheduleID = Schedule_Header.Current.ScheduleID; documentAsRegister.Scheduled = true; } DocumentSelection document = e.Row as DocumentSelection; if (document != null && !string.IsNullOrWhiteSpace(document.DocType) && !string.IsNullOrWhiteSpace(document.RefNbr) && PXSelectorAttribute.Select <DocumentSelection.refNbr>(cache, document) == null) { cache.RaiseExceptionHandling <DocumentSelection.refNbr>(document, document.RefNbr, new PXSetPropertyException(Messages.ReferenceNotValid)); Document_Detail.Cache.Remove(document); } }
protected virtual void _(Events.FieldVerifying <Customer, Customer.customerClassID> e) { Customer customerRow = (Customer)e.Row; PXCache cache = e.Cache; CustomerClass customerClassRow = (CustomerClass)PXSelectorAttribute.Select <Customer.customerClassID>(cache, customerRow, e.NewValue); this.doCopyBillingSettings = false; if (customerClassRow != null) { this.doCopyBillingSettings = true; if (cache.GetStatus(customerRow) != PXEntryStatus.Inserted && Base.UnattendedMode == false && Base.IsContractBasedAPI == false) { if (Base.CurrentCustomer.Ask(TX.WebDialogTitles.UPDATE_BILLING_SETTINGS, TX.Warning.CUSTOMER_CLASS_BILLING_SETTINGS, MessageButtons.YesNo) == WebDialogResult.No) { this.doCopyBillingSettings = false; } } } }
protected virtual void EPActivityApprove_ProjectTaskID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { EPActivityApprove row = (EPActivityApprove)e.Row; if (row == null) { return; } if (Filter.Current.ProjectTaskID != null) { e.NewValue = Filter.Current.ProjectTaskID; e.Cancel = true; return; } if (row.ParentTaskNoteID != null) { EPActivityApprove rowParentTask = PXSelect <EPActivityApprove> .Search <EPActivityApprove.noteID>(this, row.ParentTaskNoteID); if (rowParentTask != null && rowParentTask.ProjectID == row.ProjectID) { e.NewValue = rowParentTask.ProjectTaskID; e.Cancel = true; } } EPEarningType earningRow = (EPEarningType)PXSelectorAttribute.Select <EPActivityApprove.earningTypeID>(cache, row); if (e.NewValue == null && earningRow != null && earningRow.ProjectID == row.ProjectID) { PMTask defTask = PXSelectorAttribute.Select(cache, e.Row, cache.GetField(typeof(EPTimeCardSummary.projectTaskID)), earningRow.TaskID) as PMTask; if (defTask != null && defTask.VisibleInEP == true) { e.NewValue = earningRow.TaskID; e.Cancel = true; } } }
private void CheckAccountType(PXCache sender, object Row, Int32?AccountID, string AccountType) { Account account = null; if (AccountID == null) { account = (Account)PXSelectorAttribute.Select <DRDeferredCode.accountID>(sender, Row); } else { account = (Account)PXSelectorAttribute.Select <DRDeferredCode.accountID>(sender, Row, AccountID); } if (account != null && AccountType == "E" && account.Type != "A") { sender.RaiseExceptionHandling <DRDeferredCode.accountID>(Row, account.AccountCD, new PXSetPropertyException(CS.Messages.AccountTypeWarn, PXErrorLevel.Warning, GL.Messages.Asset)); } if (account != null && AccountType == "I" && account.Type != "L") { sender.RaiseExceptionHandling <DRDeferredCode.accountID>(Row, account.AccountCD, new PXSetPropertyException(CS.Messages.AccountTypeWarn, PXErrorLevel.Warning, GL.Messages.Liability)); } }
public virtual int?GetLaborClass(PMTimeActivity activity, EPEmployee employee, CRCase refCase) { if (employee == null) { throw new ArgumentNullException("employee", Messages.EmptyEmployeeID); } int?laborClassID = null; if (refCase != null) { CRCaseClass caseClass = (CRCaseClass)PXSelectorAttribute.Select <CRCase.caseClassID>(graph.Caches[typeof(CRCase)], refCase); if (caseClass.PerItemBilling == BillingTypeListAttribute.PerActivity) { laborClassID = CRCaseClassLaborMatrix.GetLaborClassID(graph, caseClass.CaseClassID, activity.EarningTypeID); } } if (laborClassID == null && activity.LabourItemID != null) { laborClassID = activity.LabourItemID; } if (laborClassID == null && activity.ProjectID != null && employee.BAccountID != null) { laborClassID = EPContractRate.GetProjectLaborClassID(graph, (int)activity.ProjectID, (int)employee.BAccountID, activity.EarningTypeID); } if (laborClassID == null) { laborClassID = EPEmployeeClassLaborMatrix.GetLaborClassID(graph, employee.BAccountID, activity.EarningTypeID); } if (laborClassID == null) { laborClassID = employee.LabourItemID; } return(laborClassID); }