public virtual IEnumerable StartTask(PXAdapter adapter) { WZTaskEntry graph = PXGraph.CreateInstance <WZTaskEntry>(); WZTask selectedTask = Tasks.Current; if (selectedTask != null && selectedTask.Status == WizardTaskStatusesAttribute._ACTIVE) { viewTask.Press(); return(adapter.Get()); } if (selectedTask != null && selectedTask.Status == WizardTaskStatusesAttribute._OPEN) { selectedTask.Status = WizardTaskStatusesAttribute._ACTIVE; graph.TaskInfo.Update(selectedTask); graph.Save.Press(); viewTask.Press(); } Tasks.Cache.ClearQueryCache(); Scenario.Cache.ClearQueryCache(); Scenario.Cache.Clear(); Scenario.View.RequestRefresh(); return(adapter.Get()); }
public override void Persist() { if (User.Current != null && User.Cache.GetStatus(User.Current) == PXEntryStatus.Inserted) { Users copy = PXCache <Users> .CreateCopy(User.Current); copy.OldPassword = User.Current.Password; copy.NewPassword = User.Current.Password; copy.ConfirmPassword = User.Current.Password; copy.FirstName = Contact.Current.FirstName; copy.LastName = Contact.Current.LastName; copy.Email = Contact.Current.EMail; copy.IsAssigned = true; User.Update(copy); } base.Persist(); if (User.Current != null && User.Current.ContactID == null && Contact.Current != null) // for correct redirection to user after inserting { User.Current.ContactID = Contact.Current.ContactID; } if (PXAccess.FeatureInstalled <FeaturesSet.contactDuplicate>() && Setup.Current.ValidateContactDuplicatesOnEntry == true) { checkForDuplicates.Press(); } }
public override void Persist() { using (PXTransactionScope ts = new PXTransactionScope()) { BAccount acct = (BAccount)BAccount.Cache.Current; if (acct != null && acct.Status == CR.BAccount.status.Inactive) { ContactMaint graph = CreateInstance <ContactMaint>(); foreach (Contact c in Contacts.Select()) { c.IsActive = false; graph.ContactCurrent.Cache.Update(c); graph.Save.Press(); } } base.Persist(); ts.Complete(); } if (Setup.Current.ValidateAccountDuplicatesOnEntry == true) { checkForDuplicates.Press(); } }
public override void Persist() { base.Persist(); if (PXAccess.FeatureInstalled <FeaturesSet.contactDuplicate>() && Setup.Current.ValidateContactDuplicatesOnEntry == true) { checkForDuplicates.Press(); } }
public override void Persist() { base.Persist(); if (Setup.Current.ValidateContactDuplicatesOnEntry == true) { checkForDuplicates.Press(); } }
public override void Persist() { if (User.Current != null && User.Cache.GetStatus(User.Current) == PXEntryStatus.Inserted) { User.Current.OldPassword = User.Current.Password; User.Current.NewPassword = User.Current.Password; User.Current.ConfirmPassword = User.Current.Password; User.Current.FirstName = Contact.Current.FirstName; User.Current.LastName = Contact.Current.LastName; User.Current.Email = Contact.Current.EMail; User.Current.IsAssigned = true; } base.Persist(); if (Setup.Current.ValidateContactDuplicatesOnEntry == true) { checkForDuplicates.Press(); } }
public static void ReverseGLVoucher(PXGraph graph, PXAction actionSave, Action baseReverse, PXCache voucherBatchView) { GLWorkBook wb = PXSelect <GLWorkBook, Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(graph, graph.GetContextValue <GLVoucherBatch.workBookID>()); if (wb?.ReversingWorkBookID == null) { throw new PXException(Messages.ReversingWorkbookIDisnotDefined); } GLWorkBook reversingWB = PXSelect <GLWorkBook, Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> >, And <GLWorkBook.status, Equal <WorkBookStatus.active> > > > .Select(graph, wb.ReversingWorkBookID); if (reversingWB == null) { throw new PXException(Messages.ReversingWorkbookIDisnotFound); } GLVoucherBatch vb = PXSelect <GLVoucherBatch, Where <GLVoucherBatch.workBookID, Equal <Required <GLWorkBook.workBookID> >, And <GLVoucherBatch.released, Equal <False> > >, OrderBy <Asc <GLVoucherBatch.voucherBatchNbr> > > .Select(graph, reversingWB.WorkBookID); if (vb == null) { var batch = new GLVoucherBatch { WorkBookID = reversingWB.WorkBookID, Descr = Messages.ReversingVoucherBatchDesc }; vb = (GLVoucherBatch)voucherBatchView.Insert(batch); voucherBatchView.Current = batch; actionSave.Press(); } graph.contextValues[typeof(GLVoucherBatch.workBookID).FullName] = reversingWB.WorkBookID; graph.contextValues[typeof(GLVoucherBatch.voucherBatchNbr).FullName] = vb.VoucherBatchNbr; baseReverse.Invoke(); throw new PXRedirectWithinContextException(graph, graph, Messages.VoucherEdit, typeof(GLVoucherBatch.workBookID), typeof(GLVoucherBatch.voucherBatchNbr)); }
private static void ProcessValidation(ValidationFilter Filter, Contact record) { PXPrimaryGraphCollection primaryGraph = new PXPrimaryGraphCollection(new PXGraph()); PXGraph graph = primaryGraph[record]; if (graph == null) { throw new PXException(Messages.UnableToFindGraph); } PXView view = graph.Views[graph.PrimaryView]; int startRow = 0, totalRows = 0; List <object> list_contact = view.Select(null, null, new object[] { record.ContactID }, new string[] { typeof(Contact.contactID).Name }, null, null, ref startRow, 1, ref totalRows); if (list_contact == null || list_contact.Count < 1) { throw new PXException(Messages.ContactNotFound); } Contact contact = PXResult.Unwrap <Contact>(list_contact[0]); contact.DuplicateFound = true; //Find duplicates view PXView viewDuplicates = graph.Views.ToArray().First(v => v.Value.Cache.GetItemType() == typeof(CRDuplicateRecord)).Value; if (viewDuplicates == null) { throw new PXException(Messages.DuplicateViewNotFound); } viewDuplicates.Clear(); List <object> duplicates = viewDuplicates.SelectMulti(); contact = (Contact)view.Cache.CreateCopy(contact); string prevStatus = contact.DuplicateStatus; contact.DuplicateStatus = DuplicateStatusAttribute.Validated; Decimal?score = 0; contact.DuplicateFound = duplicates.Count > 0; foreach (PXResult <CRDuplicateRecord, Contact, Contact2> r in duplicates) { Contact2 duplicate = r; CRDuplicateRecord contactScore = r; int duplicateWeight = ContactMaint.GetContactWeight(duplicate); int currentWeight = ContactMaint.GetContactWeight(contact); if (duplicateWeight > currentWeight || (duplicateWeight == currentWeight && duplicate.ContactID < contact.ContactID)) { contact.DuplicateStatus = DuplicateStatusAttribute.PossibleDuplicated; if (contactScore.Score > score) { score = contactScore.Score; } } } view.Cache.Update(contact); if (contact.DuplicateStatus == DuplicateStatusAttribute.PossibleDuplicated && contact.ContactType == ContactTypesAttribute.Lead && contact.Status == LeadStatusesAttribute.New && Filter.CloseNoActivityLeads == true && score > Filter.CloseThreshold) { CRActivity activity = PXSelect <CRActivity, Where <CRActivity.contactID, Equal <Required <Contact.contactID> > > > .SelectWindowed(graph, 0, 1, contact.ContactID); if (activity == null) { PXAction action = graph.Actions["Action"]; PXAdapter adapter = new PXAdapter(view); adapter.StartRow = 0; adapter.MaximumRows = 1; adapter.Searches = new object[] { contact.ContactID }; adapter.Menu = Messages.CloseAsDuplicate; adapter.SortColumns = new[] { typeof(Contact.contactID).Name }; foreach (Contact c in action.Press(adapter)) { ; } prevStatus = null; } } view.Cache.RestoreCopy(record, view.Cache.Current); if (prevStatus != contact.DuplicateStatus) { graph.Actions.PressSave(); } }
public SOInvoiceEntry() { Release.Press(); }
private void ExecuteRelease() { Release.Press(); }
protected virtual void _(Events.FieldDefaulting <SOInvoice, SOInvoice.refNbr> e) { Release.Press(); }
public IEnumerable invoices() { Release.Press(); return(new PXSelect <SOInvoice>(this).Select()); }
public IEnumerable invoices([PXString] string parameter) { Release.Press(); return(new PXSelect <SOInvoice>(this).Select()); }
public virtual IEnumerable Action( PXAdapter adapter, [PXInt] [PXIntList(new int[] { 1, 2, 3, 4, 5 }, new string[] { "Create Shipment", "Apply Assignment Rules", "Create Invoice", "Post Invoice to IN", "Create Purchase Order" })] int?actionID, [PXDate] DateTime?shipDate, [PXSelector(typeof(INSite.siteCD))] string siteCD, [SOOperation.List] string operation, [PXString()] string ActionName, Func <PXAdapter, int?, DateTime?, string, string, string, IEnumerable> baseMtd) { switch (actionID) { case 1: { if (!string.IsNullOrEmpty(ActionName)) { PXAction action = Base.Actions[ActionName]; if (action != null) { Base.Save.Press(); List <object> result = new List <object>(); foreach (object data in action.Press(adapter)) { result.Add(data); } return(result); } } List <SOOrder> list = new List <SOOrder>(); foreach (SOOrder order in adapter.Get <SOOrder>()) { list.Add(order); } if (shipDate != null) { Base.soparamfilter.Current.ShipDate = shipDate; } if (Base.soparamfilter.Current.ShipDate == null) { Base.soparamfilter.Current.ShipDate = Base.Accessinfo.BusinessDate; } if (siteCD != null) { Base.soparamfilter.Cache.SetValueExt <SOParamFilter.siteID>(Base.soparamfilter.Current, siteCD); } if (!adapter.MassProcess) { if (Base.soparamfilter.Current.SiteID == null) { Base.soparamfilter.Current.SiteID = GetPreferedSiteID(); } if (adapter.ExternalCall) { Base.soparamfilter.AskExt(true); } } if (Base.soparamfilter.Current.SiteID != null || adapter.MassProcess) { try { Base.RecalculateExternalTaxesSync = true; Base.Save.Press(); } finally { Base.RecalculateExternalTaxesSync = false; } PXAutomation.RemovePersisted(Base, typeof(SOOrder), new List <object>(list)); SOParamFilter filter = Base.soparamfilter.Current; PXLongOperation.StartOperation(Base, delegate() { bool anyfailed = false; SOShipmentEntry docgraph = PXGraph.CreateInstance <SOShipmentEntry>(); SOOrderEntry ordgraph = PXGraph.CreateInstance <SOOrderEntry>(); DocumentList <SOShipment> created = new DocumentList <SOShipment>(docgraph); //address AC-92776 for (int i = 0; i < list.Count; i++) { SOOrder order = list[i]; if (adapter.MassProcess) { PXProcessing <SOOrder> .SetCurrentItem(order); } SOOrder ordercopy = (SOOrder)Base.Caches[typeof(SOOrder)].CreateCopy(order); try { if (operation == SOOperation.Issue) { ReviewWarehouseAvailability(ordgraph, order); } } catch (SOShipmentException ex) { Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy); if (!adapter.MassProcess) { throw; } order.LastShipDate = filter.ShipDate; order.Status = SOOrderStatus.Shipping; //Automation will set the order to back order since no shipments were created docgraph.Clear(); var ordergraph = PXGraph.CreateInstance <SOOrderEntry>(); ordergraph.Clear(); ordergraph.Document.Cache.MarkUpdated(order); PXAutomation.CompleteSimple(ordergraph.Document.View); try { ordergraph.Save.Press(); PXAutomation.RemovePersisted(ordergraph, order); PXTrace.WriteInformation(ex); PXProcessing <SOOrder> .SetWarning(ex); } catch (Exception inner) { Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy); PXProcessing <SOOrder> .SetError(inner); anyfailed = true; } continue; //Stop there for this order } catch (Exception ex) { if (!adapter.MassProcess) { throw; } PXProcessing <SOOrder> .SetError(ex); anyfailed = true; continue; } List <int?> sites = new List <int?>(); if (filter.SiteID != null) { sites.Add(filter.SiteID); } else { foreach (SOShipmentPlan plan in PXSelectGroupBy <SOShipmentPlan, Where <SOShipmentPlan.orderType, Equal <Current <SOOrder.orderType> >, And <SOShipmentPlan.orderNbr, Equal <Current <SOOrder.orderNbr> > > >, Aggregate <GroupBy <SOShipmentPlan.siteID> >, OrderBy <Asc <SOShipmentPlan.siteID> > > .SelectMultiBound(docgraph, new object[] { order })) { sites.Add(plan.SiteID); } } foreach (int?SiteID in sites) { ordercopy = (SOOrder)Base.Caches[typeof(SOOrder)].CreateCopy(order); try { using (var ts = new PXTransactionScope()) { PXTimeStampScope.SetRecordComesFirst(typeof(SOOrder), true); docgraph.CreateShipment(order, SiteID, filter.ShipDate, adapter.MassProcess, operation, created, adapter.QuickProcessFlow); ts.Complete(); } if (adapter.MassProcess) { PXProcessing <SOOrder> .SetProcessed(); } } catch (SOShipmentException ex) { Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy); if (!adapter.MassProcess) { throw; } order.LastSiteID = SiteID; order.LastShipDate = filter.ShipDate; order.Status = SOOrderStatus.Shipping; docgraph.Clear(); var ordergraph = PXGraph.CreateInstance <SOOrderEntry>(); ordergraph.Clear(); ordergraph.Document.Cache.MarkUpdated(order); PXAutomation.CompleteSimple(ordergraph.Document.View); try { ordergraph.Save.Press(); PXAutomation.RemovePersisted(ordergraph, order); PXTrace.WriteInformation(ex); PXProcessing <SOOrder> .SetWarning(ex); } catch (Exception inner) { Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy); PXProcessing <SOOrder> .SetError(inner); anyfailed = true; } } catch (Exception ex) { Base.Caches[typeof(SOOrder)].RestoreCopy(order, ordercopy); docgraph.Clear(); if (!adapter.MassProcess) { throw; } PXProcessing <SOOrder> .SetError(ex); anyfailed = true; } } } if (adapter.AllowRedirect && !adapter.MassProcess && created.Count > 0) { using (new PXTimeStampScope(null)) { docgraph.Clear(); docgraph.Document.Current = docgraph.Document.Search <SOShipment.shipmentNbr>(created[0].ShipmentNbr); throw new PXRedirectRequiredException(docgraph, "Shipment"); } } if (anyfailed) { throw new PXOperationCompletedWithErrorException(ErrorMessages.SeveralItemsFailed); } }); } return(list); } default: return(baseMtd(adapter, actionID, shipDate, siteCD, operation, ActionName)); } }