public bool ValidateImportCard(CCSynchronizeCard card, int cardIndex) { bool ret = true; if (card.BAccountID == null) { PXProcessing <CCSynchronizeCard> .SetError(cardIndex, CA.Messages.CustomerNotDefined); ret = false; } if (card.PaymentMethodID == null) { PXProcessing <CCSynchronizeCard> .SetError(cardIndex, Messages.PaymentMethodNotDefined); ret = false; } if (card.CashAccountID != null) { IEnumerable <CashAccount> availableCA = PXSelectorAttribute.SelectAll <CCSynchronizeCard.cashAccountID>(this.CustomerCardPaymentData.Cache, card) .RowCast <CashAccount>(); bool exists = availableCA.Any(i => i.CashAccountID == card.CashAccountID); if (!exists) { PXProcessing <CCSynchronizeCard> .SetError(cardIndex, PXMessages.LocalizeFormatNoPrefixNLA(AR.Messages.CashAccountIsNotConfiguredForPaymentMethodInAR, card.PaymentMethodID)); ret = false; } } return(ret); }
public virtual void duplicateMerge() { List <TMain> duplicateEntities = null; bool res = MergeParam.AskExtFullyValid((graph, name) => { Base.Caches <MergeParams>().Clear(); Base.Caches <MergeParams>().Insert(); duplicateEntities = new List <TMain>(PXSelectorAttribute.SelectAll <MergeParams.targetEntityID>(Base.Caches[typeof(MergeParams)], Base.Caches[typeof(MergeParams)].Current) .RowCast <TMain>() .Select(c => Base.Caches[typeof(TMain)].CreateCopy(c)) .Cast <TMain>()); if (duplicateEntities.Count < 2) { throw new PXException(Messages.DuplicatesNotSelected); } ValidateEntitiesBeforeMerge(duplicateEntities); FillPropertyValue(); }, DialogAnswerType.Positive); if (res == false) { return; } if (duplicateEntities == null) { duplicateEntities = new List <TMain>(PXSelectorAttribute.SelectAll <MergeParams.targetEntityID>(Base.Caches[typeof(MergeParams)], Base.Caches[typeof(MergeParams)].Current) .RowCast <TMain>() .Select(c => Base.Caches[typeof(TMain)].CreateCopy(c)) .Cast <TMain>()); } int?targetID = ((MergeParams)Base.Caches[typeof(MergeParams)].Current).TargetEntityID; List <FieldValue> values = new List <FieldValue>(Base.Caches[typeof(FieldValue)].Cached.Cast <FieldValue>() .Select(v => Base.Caches[typeof(FieldValue)].CreateCopy(v)) .Cast <FieldValue>()); Base.Actions.PressSave(); PXLongOperation.StartOperation(Base, () => MergeDuplicates( (int)targetID, duplicateEntities, values, Base.IsContractBasedAPI)); }
public override void Initialize() { try { var fullName = Base.GetType().Namespace + '.' + Base.GetType().Name; //if (Base.GetType().Name == "CustomerMaint") { PowerTabAssignment.Current = PowerTabAssignment.Select(fullName); if (PowerTabAssignment.Current != null) { var paramMap = PowerTabMapping.Select(); if (paramMap != null) { var ptParams = new Dictionary <string, string>(); foreach (GIMappingLine param in paramMap) { //var cleanName = param.FieldName.Split('.').Last(); ptParams.Add(param.ParamName, param.FieldName); } //PowerTabSource.Current = new PTSource(); //PowerTabSource.Current.PowerTabUrl = BuildSource("GI", PowerTabAssignment.Current.DesignID, ptParams); // ptParams.Add("CustomerAccountID", "AcctCD"); //BuildSource("DB", "DB000031", ptParams); Base.RowSelected.AddHandler(Base.PrimaryView, (cache, args) => { if (PowerTabSource?.Current == null) { PowerTabSource.Current = new PTSource(); } PowerTabAssignment.Current = PowerTabAssignment.Select(fullName); var giName = ((GIDesign)PXSelectorAttribute.SelectAll <GIMapping.designID>(PowerTabAssignment.Cache, PowerTabAssignment.Current).Find(map => ((GIDesign)map).DesignID == PowerTabAssignment.Current.DesignID))?.Name; PowerTabSource.Current.PowerTabUrl = BuildSource("GI", giName, ptParams); }); } } } catch (Exception ex) { PXTrace.WriteError(ex); } }
protected virtual void _(Events.FieldDefaulting <MergeParams, MergeParams.targetEntityID> e) { TMain current = (TMain)Base.Caches <TMain>().Current; List <TMain> duplicates = PXSelectorAttribute.SelectAll <MergeParams.targetEntityID>(e.Cache, e.Row) .RowCast <TMain>() .ToList(); e.NewValue = current.IsActive == true || duplicates.Count == 0 ? current.ContactID : duplicates .OrderBy(duplicate => duplicate?.ContactID) .FirstOrDefault() ?.ContactID; }
public void CABatch_ProcessingCenterID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { var ret = string.Empty; foreach (PXResult <CCProcessingCenterPmntMethod, CCProcessingCenter> proc in PXSelectorAttribute.SelectAll <CABatchExt.processingCenterID>(sender, e.Row)) { var pmtMethod = (CCProcessingCenterPmntMethod)proc; ret = pmtMethod.ProcessingCenterID; if (pmtMethod.IsDefault == true) { break; } } e.NewValue = ret; }
protected PXFieldState InitValueFieldState(FieldValue field) { Tuple <IEnumerable <string>, IEnumerable <string> > possibleValues = new Tuple <IEnumerable <string>, IEnumerable <string> >(new string[0], new string[0]); List <TMain> entities = new List <TMain>(PXSelectorAttribute.SelectAll <MergeParams.targetEntityID>(Base.Caches[typeof(MergeParams)], Base.Caches[typeof(MergeParams)].Current).RowCast <TMain>()); if (field.CacheName == typeof(TMain).FullName) { possibleValues = GetPossibleValues(Base, entities, field.Name); } else if (field.CacheName == typeof(Contact).FullName && field.CacheName != typeof(TMain).FullName) { PXSelectBase <Contact> cmd = new PXSelect <Contact>(Base); List <int?> defContactIDs = new List <int?>(entities.Select(entity => Base.Caches[typeof(TMain)].GetValue(entity, nameof(Document.DefContactID)) as int?).Where(c => c != null)); foreach (int?c in defContactIDs) { cmd.WhereOr <Where <Contact.contactID, Equal <Required <BAccount.defContactID> > > >(); } possibleValues = GetPossibleValues(Base, cmd.Select(defContactIDs.Cast <object>().ToArray()).RowCast <Contact>(), field.Name); } else if (field.CacheName == typeof(Address).FullName) { PXSelectBase <Address> cmd = new PXSelect <Address>(Base); List <int?> addressIDs = new List <int?>(entities.Select(entity => Base.Caches[typeof(TMain)].GetValue(entity, nameof(Document.DefAddressID)) as int?).Where(c => c != null)); foreach (int?a in addressIDs) { cmd.WhereOr <Where <Address.addressID, Equal <Required <Address.addressID> > > >(); } possibleValues = GetPossibleValues(Base, cmd.Select(addressIDs.Cast <object>().ToArray()).RowCast <Address>(), field.Name); } string[] values = possibleValues.Item1.ToArray(); string[] labels = possibleValues.Item2.ToArray(); return(PXStringState.CreateInstance(field.Value, null, null, typeof(FieldValue.value).Name, false, 0, null, values, labels, null, null)); }