protected virtual IEnumerable viewHandler() { if (intView == null) { intView = CreateIntView(View.Graph); } int startRow = PXView.StartRow; int num = 0; PXDelegateResult pXDelegateResult = new PXDelegateResult(); foreach (object obj in intView.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref num)) { var statu = PXResult.Unwrap <RowToSelect>(obj); var statu1 = statu; var statu2 = (Cache.Locate(statu) as RowToSelect); if (statu2 != null) { bool?value = (Cache.GetValue(statu2, Selected) as bool?); if (value.GetValueOrDefault() & value.HasValue) { Cache.RestoreCopy(statu2, statu); Cache.SetValue(statu2, Selected, true); statu1 = statu2; } } pXDelegateResult.Add(statu1); } PXView.StartRow = 0; if (PXView.ReverseOrder) { pXDelegateResult.Reverse(); } pXDelegateResult.IsResultSorted = true; return(pXDelegateResult); }
protected override TaxDetail CalculateTaxSum(PXCache sender, object taxrow, object row) { TaxRev taxrev = PXResult.Unwrap <TaxRev>(taxrow); Tax tax = PXResult.Unwrap <Tax>(taxrow); bool propagateCustomRate = false; var origTaxRate = taxrev.TaxRate; if (taxrev.TaxID != null && tax != null) { SOTaxAmazonExt taxExt = tax.GetExtension <SOTaxAmazonExt>(); if (taxExt.UsrAMPropagateTaxAmt == true) { SOTaxTran soTax = PXResult <SOTaxTran> .Current; if (soTax != null && taxrev.TaxID == soTax.TaxID && soTax.CuryTaxableAmt.GetValueOrDefault() > 0) { var taxRate = soTax.CuryTaxAmt / soTax.CuryTaxableAmt * 100; if (taxRate != origTaxRate && taxRate > 0) { taxrev.TaxRate = taxRate; propagateCustomRate = true; } } } } TaxDetail result = base.CalculateTaxSum(sender, taxrow, row); if (result != null && propagateCustomRate) { result.TaxRate = origTaxRate; taxrev.TaxRate = origTaxRate; } return(result); }
public virtual void RenumberAll(IComparer <PXResult> comparer) { PXResultset <Table> res = Select(); List <PXResult> list = new List <PXResult>(res.Count); foreach (PXResult item in res) { list.Add(item); } list.Sort(comparer); int sortorder = 0; foreach (PXResult item in list) { sortorder++; Table line = PXResult.Unwrap <Table>(item); if (line.SortOrder != sortorder) { Cache.SetValue(line, nameof(ISortOrder.SortOrder), sortorder); Cache.SmartSetStatus(line, PXEntryStatus.Updated); Cache.IsDirty = true; } } View.Clear(); //clears stored cache so that grid lines are reordered. }
private (List <object> PerUnitInclusiveTaxes, List <object> PerUnitLevel1Taxes) GetNonExcludedPerUnitTaxesByCalculationLevel(List <object> allPerUnitTaxes) { List <object> perUnitLevel1Taxes = new List <object>(capacity: allPerUnitTaxes.Count); List <object> perUnitInclusiveTaxes = new List <object>(capacity: allPerUnitTaxes.Count); foreach (object taxRow in allPerUnitTaxes) { Tax perUnitTax = PXResult.Unwrap <Tax>(taxRow); if (perUnitTax.TaxCalcLevel2Exclude != false) { continue; } switch (perUnitTax.TaxCalcLevel) { case CSTaxCalcLevel.CalcOnItemQtyInclusively: perUnitInclusiveTaxes.Add(taxRow); continue; case CSTaxCalcLevel.CalcOnItemQtyExclusively: perUnitLevel1Taxes.Add(taxRow); continue; } } return(perUnitInclusiveTaxes, perUnitLevel1Taxes); }
public override void CacheAttached(PXCache sender) { base.CacheAttached(sender); PXView outerview = new PXView(sender.Graph, true, _Select); PXView view = sender.Graph.Views[_ViewName] = new PXView(sender.Graph, true, _Select, (PXSelectDelegate) delegate() { int startRow = PXView.StartRow; int totalRows = 0; List <object> res; using (new PXReadBranchRestrictedScope()) { res = outerview.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows); PXView.StartRow = 0; } PXCache cache = outerview.Graph.Caches[typeof(INSite)]; return(res.FindAll((item) => { return _RestrictedSelect.Meet(cache, item is PXResult ? PXResult.Unwrap <INSite>(item) : item); })); }); if (_DirtyRead) { view.IsReadOnly = false; } }
protected virtual void TaxTotal_CuryTaxableAmt_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { TaxTotal taxdetOrig = sender.GetExtension <TaxTotal>(e.Row); if (taxdetOrig == null) { return; } decimal newValue = (decimal)(sender.GetValue(e.Row, typeof(TaxTotal.curyTaxableAmt).Name) ?? 0m); decimal oldValue = (decimal)(e.OldValue ?? 0m); if (CurrentDocument.TaxCalc != TaxCalc.NoCalc && e.ExternalCall && newValue != oldValue) { foreach (object taxrow in SelectTaxes < Where <Tax.taxID, Equal <Required <Tax.taxID> > > >(sender.Graph, null, PXTaxCheck.RecalcTotals, taxdetOrig.RefTaxID)) { TaxTotal taxdet = sender.GetExtension <TaxTotal>(((PXResult)taxrow)[0]); Tax tax = PXResult.Unwrap <Tax>(taxrow); TaxRev taxrev = PXResult.Unwrap <TaxRev>(taxrow); CalculateTaxSumTaxAmt(taxdet, tax, taxrev); } } }
public object CreateResult(PXResult source) { var result = new Dictionary <Type, object>(); foreach (Type type in resultDefinition) { object resultItem = PXResult.Unwrap(source, type) ?? this.graph.Caches[type].CreateInstance(); result.Add(type, resultItem); } foreach (Type field in fieldMap.Keys) { Type sourceType = fieldMap[field]; Type dac = sourceType.DeclaringType; PXCache cacheGet = graph.Caches[dac]; PXCache cacheSet = graph.Caches[field.DeclaringType]; cacheSet.SetValue(result[field.DeclaringType], field.Name, cacheGet.GetValue(PXResult.Unwrap(source, dac), sourceType.Name)); } if (resultDefinition.Length == 1) { return(result[resultDefinition[0]]); } else { Type generic = GetResultType(); object[] data = new object[resultDefinition.Length]; for (int i = 0; i < resultDefinition.Length; i++) { data[i] = result[resultDefinition[i]]; } return(Activator.CreateInstance(generic.MakeGenericType(resultDefinition), data)); } }
public override void ProccessItem(PXGraph graph, TPrimary item) { PXCache cache = graph.Caches[typeof(TPrimary)]; TPrimary newItem = (TPrimary)cache.CreateInstance(); PXCache <TPrimary> .RestoreCopy(newItem, item); string entityType = CSAnswerType.GetAnswerType(cache.GetItemType()); string entityID = CSAnswerType.GetEntityID(cache.GetItemType()); PXView primaryView = graph.Views[graph.PrimaryView]; object[] searches = new object[primaryView.Cache.BqlKeys.Count]; string[] sortcolumns = new string[primaryView.Cache.BqlKeys.Count]; for (int i = 0; i < cache.BqlKeys.Count(); i++) { sortcolumns[i] = cache.BqlKeys[i].Name; searches[i] = cache.GetValue(newItem, sortcolumns[i]); } int startRow = 0, totalRows = 0; List <object> result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows); newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0])); foreach (FieldValue fieldValue in Fields.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID == null && o.Selected == true)) { PXFieldState state = cache.GetStateExt(newItem, fieldValue.Name) as PXFieldState; PXIntState intState = state as PXIntState; PXStringState strState = state as PXStringState; if ((intState != null && intState.AllowedValues != null && intState.AllowedValues.Length > 0 && intState.AllowedValues.All(v => v != int.Parse(fieldValue.Value))) || (strState != null && strState.AllowedValues != null && strState.AllowedValues.Length > 0 && strState.AllowedValues.All(v => v != fieldValue.Value))) { throw new PXSetPropertyException(ErrorMessages.UnallowedListValue, fieldValue.Value, fieldValue.Name); } if (state != null && !Equals(state.Value, fieldValue.Value)) { cache.SetValueExt(newItem, fieldValue.Name, fieldValue.Value); cache.Update(newItem); } result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows); newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0])); } PXCache attrCache = cache.Graph.Caches[typeof(CSAnswers)]; foreach (FieldValue attrValue in Attributes.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID != null && o.Selected == true)) { CSAnswers attr = (CSAnswers)attrCache.CreateInstance(); attr.AttributeID = attrValue.AttributeID; attr.EntityID = cache.GetValue(newItem, entityID) as int?; attr.EntityType = entityType; attr.Value = attrValue.Value; attrCache.Update(attr); } }
public IEnumerable GetRecords() { BqlCommand command = BqlCommand.CreateInstance(search); PXView view = new PXView(_Graph, false, command); foreach (object obj in view.SelectMulti()) { CCProcessingCenter procCenter = PXResult.Unwrap <CCProcessingCenter>(obj); if (CheckPluginType(procCenter)) { yield return(obj); } } }
protected virtual void _(Events.RowDeleted <ARInvoice> e) { var select = new PXSelectJoin <PMBillingRecord, LeftJoin <PMProforma, On <PMBillingRecord.proformaRefNbr, Equal <PMProforma.refNbr> > >, Where <PMBillingRecord.aRDocType, Equal <Required <PMBillingRecord.aRDocType> >, And <PMBillingRecord.aRRefNbr, Equal <Required <PMBillingRecord.aRRefNbr> > > > >(Base); var resultset = select.Select(e.Row.DocType, e.Row.RefNbr); if (resultset.Count > 0) { PMBillingRecord billingRecord = PXResult.Unwrap <PMBillingRecord>(resultset[0]); if (billingRecord != null) { if (billingRecord.ProformaRefNbr != null) { billingRecord.ARDocType = null; billingRecord.ARRefNbr = null; ProjectBillingRecord.Update(billingRecord); PMProforma proforma = PXResult.Unwrap <PMProforma>(resultset[0]); if (proforma != null && !string.IsNullOrEmpty(proforma.RefNbr)) { proforma.ARInvoiceDocType = null; proforma.ARInvoiceRefNbr = null; proforma.Released = false; proforma.Status = ProformaStatus.Open; ProjectProforma.Update(proforma); } } else { ProjectBillingRecord.Delete(billingRecord); } } PMRegister allocationReversal = PXSelect <PMRegister, Where <PMRegister.origDocType, Equal <PMOrigDocType.allocationReversal>, And <PMRegister.origNoteID, Equal <Required <ARInvoice.noteID> >, And <PMRegister.released, Equal <False> > > > > .Select(Base, e.Row.NoteID); if (allocationReversal != null) { ProjectRegister.Delete(allocationReversal); } } AddToUnbilledSummary(e.Row); }
protected virtual ProjectsList CreateListItem(PXResult item) { PMProject project = PXResult.Unwrap <PMProject>(item); ContractBillingSchedule schedule = PXResult.Unwrap <ContractBillingSchedule>(item); Customer customer = PXResult.Unwrap <Customer>(item); ProjectsList result = new ProjectsList(); result.ProjectID = project.ContractID; result.ProjectCD = project.ContractCD; result.Description = project.Description; result.CustomerID = project.CustomerID; result.LastDate = schedule.LastDate; DateTime?fromDate = null; if (schedule.NextDate != null) { switch (schedule.Type) { case BillingType.Annual: fromDate = schedule.NextDate.Value.AddYears(-1); break; case BillingType.Monthly: fromDate = schedule.NextDate.Value.AddMonths(-1); break; case BillingType.Weekly: fromDate = schedule.NextDate.Value.AddDays(-7); break; case BillingType.Quarterly: fromDate = schedule.NextDate.Value.AddMonths(-3); break; } } result.FromDate = fromDate; result.NextDate = schedule.NextDate; return(result); }
protected virtual void Tax_CuryTaxableAmt_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { TaxDetail taxdetOrig = e.Row as TaxDetail; if (taxdetOrig == null) return; decimal newValue = (decimal)(sender.GetValue(e.Row, _CuryTaxableAmt) ?? 0m); decimal oldValue = (decimal)(e.OldValue ?? 0m); if (_TaxCalc != TaxCalc.NoCalc && e.ExternalCall && newValue != oldValue) { foreach (object taxrow in SelectTaxes< Where<Tax.taxID, Equal<Required<Tax.taxID>>>>(sender.Graph, null, PXTaxCheck.RecalcTotals, taxdetOrig.TaxID)) { TaxDetail taxdet = (TaxDetail)((PXResult)taxrow)[0]; Tax tax = PXResult.Unwrap<Tax>(taxrow); TaxRev taxrev = PXResult.Unwrap<TaxRev>(taxrow); CalculateTaxSumTaxAmt(sender, taxdet, tax, taxrev); } } }
protected virtual IEnumerable items() { BillingFilter filter = Filter.Current; if (filter == null) { yield break; } bool found = false; foreach (ProjectsList item in Items.Cache.Inserted) { found = true; yield return(item); } if (found) { yield break; } PXSelectBase <PMProject> selectUnbilled = new PXSelectJoinGroupBy <PMProject, InnerJoin <PMUnbilledDailySummary, On <PMUnbilledDailySummary.projectID, Equal <PMProject.contractID> >, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMUnbilledDailySummary.projectID>, And <PMTask.isActive, Equal <True>, And <PMTask.taskID, Equal <PMUnbilledDailySummary.taskID>, And <Where <PMTask.billingOption, Equal <PMBillingOption.onBilling>, Or2 <Where <PMTask.billingOption, Equal <PMBillingOption.onTaskCompletion>, And <PMTask.isCompleted, Equal <True> > >, Or <Where <PMTask.billingOption, Equal <PMBillingOption.onProjectCompetion>, And <PMProject.isCompleted, Equal <True> > > > > > > > > >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID>, And <PMBillingRule.accountGroupID, Equal <PMUnbilledDailySummary.accountGroupID> > > > > > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And2 <Where <PMBillingRule.includeNonBillable, Equal <False>, And <PMUnbilledDailySummary.billable, Greater <int0>, Or <Where <PMBillingRule.includeNonBillable, Equal <True>, And <Where <PMUnbilledDailySummary.nonBillable, Greater <int0>, Or <PMUnbilledDailySummary.billable, Greater <int0> > > > > > > >, And2 <Where <PMUnbilledDailySummary.date, LessEqual <Current <BillingFilter.invoiceDate> > >, And <Match <Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <PMProject.contractID> > >(this); if (Setup.Current.CutoffDate == PMCutOffDate.Excluded) { selectUnbilled = new PXSelectJoinGroupBy <PMProject, InnerJoin <PMUnbilledDailySummary, On <PMUnbilledDailySummary.projectID, Equal <PMProject.contractID> >, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMUnbilledDailySummary.projectID>, And <PMTask.isActive, Equal <True>, And <PMTask.taskID, Equal <PMUnbilledDailySummary.taskID>, And <Where <PMTask.billingOption, Equal <PMBillingOption.onBilling>, Or2 <Where <PMTask.billingOption, Equal <PMBillingOption.onTaskCompletion>, And <PMTask.isCompleted, Equal <True> > >, Or <Where <PMTask.billingOption, Equal <PMBillingOption.onProjectCompetion>, And <PMProject.isCompleted, Equal <True> > > > > > > > > >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID>, And <PMBillingRule.accountGroupID, Equal <PMUnbilledDailySummary.accountGroupID> > > > > > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And2 <Where <PMBillingRule.includeNonBillable, Equal <False>, And <PMUnbilledDailySummary.billable, Greater <int0>, Or <Where <PMBillingRule.includeNonBillable, Equal <True>, And <Where <PMUnbilledDailySummary.nonBillable, Greater <int0>, Or <PMUnbilledDailySummary.billable, Greater <int0> > > > > > > >, And2 <Where <PMUnbilledDailySummary.date, Less <Current <BillingFilter.invoiceDate> > >, And <Match <Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <PMProject.contractID> > >(this); } PXSelectBase <PMProject> selectRecurring = new PXSelectJoinGroupBy <PMProject, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMProject.contractID> >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID> >, InnerJoin <PMRecurringItem, On <PMTask.projectID, Equal <PMRecurringItem.projectID>, And <PMTask.taskID, Equal <PMRecurringItem.taskID>, And <PMTask.isCompleted, Equal <False> > > > > > > > >, Where2 <Where <ContractBillingSchedule.nextDate, LessEqual <Current <BillingFilter.invoiceDate> >, Or <ContractBillingSchedule.type, Equal <BillingType.BillingOnDemand> > >, And <Match <Current <AccessInfo.userName> > > >, Aggregate <GroupBy <PMProject.contractID> > >(this); PXSelectBase <PMProject> selectProgressive = new PXSelectJoinGroupBy <PMProject, InnerJoin <ContractBillingSchedule, On <PMProject.contractID, Equal <ContractBillingSchedule.contractID> >, InnerJoin <Customer, On <PMProject.customerID, Equal <Customer.bAccountID> >, InnerJoin <PMTask, On <PMTask.projectID, Equal <PMProject.contractID> >, InnerJoin <PMBillingRule, On <PMBillingRule.billingID, Equal <PMTask.billingID> >, InnerJoin <PMBudget, On <PMTask.projectID, Equal <PMBudget.projectID>, And <PMTask.taskID, Equal <PMBudget.projectTaskID>, And <PMBudget.type, Equal <GL.AccountType.income>, And <PMBudget.amountToInvoice, NotEqual <decimal0> > > > > > > > > >, Where <Match <Current <AccessInfo.userName> > >, Aggregate <GroupBy <PMProject.contractID> > >(this); if (filter.StatementCycleId != null) { selectUnbilled.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); selectRecurring.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); selectProgressive.WhereAnd <Where <Customer.statementCycleId, Equal <Current <BillingFilter.statementCycleId> > > >(); } if (filter.CustomerClassID != null) { selectUnbilled.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); selectRecurring.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); selectProgressive.WhereAnd <Where <Customer.customerClassID, Equal <Current <BillingFilter.customerClassID> > > >(); } if (filter.CustomerID != null) { selectUnbilled.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); selectRecurring.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); selectProgressive.WhereAnd <Where <Customer.bAccountID, Equal <Current <BillingFilter.customerID> > > >(); } if (filter.TemplateID != null) { selectUnbilled.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); selectRecurring.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); selectProgressive.WhereAnd <Where <PMProject.templateID, Equal <Current <BillingFilter.templateID> > > >(); } foreach (PXResult item in selectUnbilled.Select().Union(selectRecurring.Select()).Union(selectProgressive.Select())) { PMProject project = PXResult.Unwrap <PMProject>(item); ContractBillingSchedule schedule = PXResult.Unwrap <ContractBillingSchedule>(item); Customer customer = PXResult.Unwrap <Customer>(item); ProjectsList result = new ProjectsList(); result.ProjectID = project.ContractID; result.ProjectCD = project.ContractCD; result.Description = project.Description; result.CustomerID = project.CustomerID; result.CustomerName = customer.AcctName; result.LastDate = schedule.LastDate; DateTime?fromDate = null; if (schedule.NextDate != null) { switch (schedule.Type) { case BillingType.Annual: fromDate = schedule.NextDate.Value.AddYears(-1); break; case BillingType.Monthly: fromDate = schedule.NextDate.Value.AddMonths(-1); break; case BillingType.Weekly: fromDate = schedule.NextDate.Value.AddDays(-7); break; case BillingType.Quarterly: fromDate = schedule.NextDate.Value.AddMonths(-3); break; } } result.FromDate = fromDate; result.NextDate = schedule.NextDate; if (Items.Locate(result) == null) { yield return(Items.Insert(result)); } } Items.Cache.IsDirty = false; }
public virtual IEnumerable orders() { PXUIFieldAttribute.SetDisplayName <SOShipment.customerID>(Caches[typeof(SOShipment)], Messages.CustomerID); SOShipmentFilter filter = Filter.Current; if (filter.Action == "<SELECT>") { yield break; } string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID"); int action = 0; int.TryParse(actionID, out action); if (_ActionChanged) { Orders.Cache.Clear(); } PXSelectBase cmd; switch (action) { case SOShipmentEntryActionsAttribute.CreateInvoice: cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> >, InnerJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType, Equal <SOOrderShipment.orderType>, And <SOOrderTypeOperation.operation, Equal <SOOrderShipment.operation> > >, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> >, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> > > > > > > > >, Where <SOShipment.confirmed, Equal <boolTrue>, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>, And <SOOrderShipment.invoiceNbr, IsNull, And2 <Match <Customer, Current <AccessInfo.userName> >, And <Match <INSite, Current <AccessInfo.userName> > > > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.insurance, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; case SOShipmentEntryActionsAttribute.PostInvoiceToIN: cmd = new PXSelectJoinGroupBy <SOShipment, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOShipLine, On <SOShipLine.shipmentType, Equal <SOOrderShipment.shipmentType>, And <SOShipLine.shipmentNbr, Equal <SOOrderShipment.shipmentNbr>, And <SOShipLine.origOrderType, Equal <SOOrderShipment.orderType>, And <SOShipLine.origOrderNbr, Equal <SOOrderShipment.orderNbr> > > > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >, LeftJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> > > > > > > > >, Where <SOShipment.confirmed, Equal <boolTrue>, And <SOOrderShipment.invtRefNbr, IsNull, And <SOShipLine.lineType, Equal <SOLineType.inventory>, And <SOOrderType.iNDocType, NotEqual <INTranType.noUpdate>, And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >, And <Match <INSite, Current <AccessInfo.userName> > > > > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; case SOShipmentEntryActionsAttribute.CreateDropshipInvoice: cmd = new PXSelectJoinGroupBy <POReceipt, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentNbr, Equal <POReceipt.receiptNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipmentType.dropShip> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> >, InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> >, InnerJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType, Equal <SOOrderShipment.orderType>, And <SOOrderTypeOperation.operation, Equal <SOOrderShipment.operation> > > > > > > >, Where <POReceipt.released, Equal <boolTrue>, //And2<Where<POReceiptLine.lineType, Equal<POLineType.goodsForDropShip>, Or<POReceiptLine.lineType, Equal<POLineType.nonStockForDropShip>>>, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>, And <SOOrderShipment.invoiceNbr, IsNull, And <Match <Customer, Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <POReceipt.receiptNbr, GroupBy <POReceipt.createdByID, GroupBy <POReceipt.lastModifiedByID, GroupBy <POReceipt.released, GroupBy <POReceipt.ownerID, GroupBy <POReceipt.hold> > > > > > > >(this); break; case SOShipmentEntryActionsAttribute.CancelReturn: cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >, InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > > >, Where <SOShipment.labelsPrinted, Equal <False>, And2 <Match <Customer, Current <AccessInfo.userName> >, And <Match <INSite, Current <AccessInfo.userName> > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; default: cmd = new PXSelectJoinGroupBy <SOShipment, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >, LeftJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > > >, Where2 <Match <INSite, Current <AccessInfo.userName> >, And <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; } if (typeof(PXSelectBase <SOShipment>).IsAssignableFrom(cmd.GetType())) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, LessEqual <Current <SOShipmentFilter.endDate> > > >(); if (filter.SiteID != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.siteID, Equal <Current <SOShipmentFilter.siteID> > > >(); } if (!string.IsNullOrEmpty(filter.CarrierPluginID)) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >(); } if (!string.IsNullOrEmpty(filter.ShipVia)) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >(); } if (filter.StartDate != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >(); } if (filter.CustomerID != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >(); } if (action == SOShipmentEntryActionsAttribute.PrintLabels && filter.ShowPrinted == false) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.labelsPrinted, Equal <False> > >(); } if (action == SOShipmentEntryActionsAttribute.PrintPickList && filter.ShowPrinted == false) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.pickListPrinted, Equal <False> > >(); } if (filter.PackagingType == SOShipmentFilter.Manual) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, Equal <True> > >(); } else if (filter.PackagingType == SOShipmentFilter.Auto) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, NotEqual <True> > >(); } int startRow = PXView.StartRow; int totalRows = 0; List <PXFilterRow> newFilters = new List <PXFilterRow>(); foreach (PXFilterRow f in PXView.Filters) { if (string.Compare(f.DataField, "CustomerOrderNbr", StringComparison.OrdinalIgnoreCase) == 0) { f.DataField = "SOOrder__CustomerOrderNbr"; } newFilters.Add(f); } foreach (object res in ((PXSelectBase <SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, newFilters.ToArray(), ref startRow, PXView.MaximumRows, ref totalRows)) { SOShipment order = PXResult.Unwrap <SOShipment>(res); SOOrder so = PXResult.Unwrap <SOOrder>(res); if (order.BilledOrderCntr + order.UnbilledOrderCntr + order.ReleasedOrderCntr == 1) { order.CustomerOrderNbr = so.CustomerOrderNbr; } SOShipment cached = (SOShipment)Orders.Cache.Locate(order); if (cached != null) { order.Selected = cached.Selected; } yield return(order); } PXView.StartRow = 0; } if (typeof(PXSelectBase <POReceipt>).IsAssignableFrom(cmd.GetType())) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, LessEqual <Current <SOShipmentFilter.endDate> > > >(); /* * if (filter.SiteID != null) * { * ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.siteID, Equal<Current<SOShipmentFilter.siteID>>>>(); * } * * if (!string.IsNullOrEmpty(filter.ShipVia)) * { * ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.shipVia, Equal<Current<SOShipmentFilter.shipVia>>>>(); * } */ if (filter.StartDate != null) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >(); } foreach (PXResult <POReceipt, SOOrderShipment, SOOrder> res in ((PXSelectBase <POReceipt>)cmd).Select()) { SOShipment order = res; SOShipment cached = (SOShipment)Orders.Cache.Locate(order); if (cached == null) { Orders.Cache.SetStatus(order, PXEntryStatus.Held); } else { order.Selected = cached.Selected; } yield return(order); } } Orders.Cache.IsDirty = false; }
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(); } }
private List <Recipient> GetMailsForSending(bool onlyFirst) { var mailKeys = new HashSet <string>(StringComparer.OrdinalIgnoreCase); var mails = new List <Recipient>(); switch (MassMails.Current.Source) { case CRMassMailSourcesAttribute.MailList: ResetView(MailListsExt.View); foreach (CRMarketingList list in MailLists.Select()) { if (list.Selected == true) { var marketingGraph = PXGraph.CreateInstance <CRMarketingListMaint>(); marketingGraph.MailLists.Current = list; IEnumerable rows = marketingGraph.MailRecipients.Select(); foreach (PXResult row in rows) { var contact = PXResult.Unwrap <Contact>(row); if (contact.NoMassMail == true || contact.NoEMail == true || contact.NoMail == true || contact.NoCall == true || contact.NoFax == true || contact.NoMarketing == true) { continue; } var subscription = PXResult.Unwrap <CRMarketingListMember>(row); if (subscription?.IsSubscribed != true) { continue; } var address = contact.EMail; if (address != null && (address = address.Trim()) != string.Empty && !mailKeys.Contains(address)) { mailKeys.Add(address); mails.Add(new Recipient(list, contact, subscription.Return(s => s.Format, NotificationFormat.Html))); if (onlyFirst) { break; } } } if (mails.Count > 0 && onlyFirst) { break; } } } break; case CRMassMailSourcesAttribute.Campaign: ResetView(Campaigns.View); foreach (CRCampaign list in Campaigns.Select()) { if (list.Selected == true) { Campaigns.Cache.Current = list; var select = new PXSelectJoin < Contact, InnerJoin <CRCampaignMembers, On <CRCampaignMembers.contactID, Equal <Contact.contactID> > >, Where < GDPR.ContactExt.pseudonymizationStatus, NotEqual <PXPseudonymizationStatusListAttribute.pseudonymized>, And <GDPR.ContactExt.pseudonymizationStatus, NotEqual <PXPseudonymizationStatusListAttribute.erased>, And <Contact.noMassMail, NotEqual <True>, And <Contact.noEMail, NotEqual <True>, And <Contact.noMarketing, NotEqual <True>, And <CRCampaignMembers.campaignID, Equal <Required <CRCampaignMembers.campaignID> > > > > > > > >(this); if (list.SendFilter == SendFilterSourcesAttribute._NEVERSENT) { select.WhereAnd <Where <CRCampaignMembers.emailSendCount, Equal <Zero> > >(); } foreach (PXResult <Contact, CRCampaignMembers> item in select.Select(list.CampaignID)) { var contact = (Contact)item; var address = contact.EMail; if (address != null && (address = address.Trim()) != string.Empty && !mailKeys.Contains(address)) { mailKeys.Add(address); mails.Add(new Recipient(list, contact, NotificationFormat.Html)); if (onlyFirst) { break; } } } if (mails.Count > 0 && onlyFirst) { break; } } } break; case CRMassMailSourcesAttribute.Lead: foreach (Contact contact in Leads.Select()) { if (contact.Selected == true) { var address = contact.EMail; if (address != null && (address = address.Trim()) != string.Empty && !mailKeys.Contains(address)) { mailKeys.Add(address); mails.Add(new Recipient(contact, NotificationFormat.Html)); if (onlyFirst) { break; } } } } break; } return(mails); }
public virtual IEnumerable orders() { PXUIFieldAttribute.SetDisplayName <SOShipment.shipVia_Carrier_description>(Caches[typeof(SOShipment)], Messages.CarrierDescr); PXUIFieldAttribute.SetDisplayName <SOShipment.siteID_INSite_descr>(Caches[typeof(SOShipment)], Messages.SiteDescr); PXUIFieldAttribute.SetDisplayName <SOShipment.customerID>(Caches[typeof(SOShipment)], Messages.CustomerID); SOShipmentFilter filter = Filter.Current; if (filter.Action == "<SELECT>") { yield break; } string actionID = (string)Orders.GetTargetFill(null, null, null, filter.Action, "@actionID"); if (_ActionChanged) { Orders.Cache.Clear(); } foreach (SOShipment order in Orders.Cache.Updated) { yield return(order); } PXSelectBase cmd; switch (actionID) { case "2": cmd = new PXSelectJoinGroupBy <SOShipment, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <SOShipLine, On <SOShipLine.shipmentNbr, Equal <SOShipment.shipmentNbr> >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOShipLine.origOrderType> >, InnerJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType, Equal <SOShipLine.origOrderType>, And <SOOrderTypeOperation.operation, Equal <SOShipment.operation> > >, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, LeftJoin <ARTran, On <ARTran.sOShipmentNbr, Equal <SOShipLine.shipmentNbr>, And <ARTran.sOShipmentType, NotEqual <SOShipmentType.dropShip>, And <ARTran.sOShipmentLineNbr, Equal <SOShipLine.lineNbr> > > > > > > > > > >, Where <SOShipment.confirmed, Equal <boolTrue>, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>, And <ARTran.refNbr, IsNull, And <Match <INSite, Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.insurance, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; case "3": cmd = new PXSelectJoinGroupBy <SOShipment, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOShipLine, On <SOShipLine.shipmentType, Equal <SOOrderShipment.shipmentType>, And <SOShipLine.shipmentNbr, Equal <SOOrderShipment.shipmentNbr>, And <SOShipLine.origOrderType, Equal <SOOrderShipment.orderType>, And <SOShipLine.origOrderNbr, Equal <SOOrderShipment.orderNbr> > > > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOShipLine.origOrderType>, And <SOOrder.orderNbr, Equal <SOShipLine.origOrderNbr> > >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> > > > > > > >, Where <SOShipment.confirmed, Equal <boolTrue>, And <SOOrderShipment.invtRefNbr, IsNull, And <SOShipLine.lineType, Equal <SOLineType.inventory>, And <SOOrderType.iNDocType, NotEqual <INTranType.noUpdate>, And <Match <INSite, Current <AccessInfo.userName> > > > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; case "6": cmd = new PXSelectJoinGroupBy <POReceipt, CrossJoin <SOOrder, InnerJoin <POReceiptLine, On <POReceiptLine.receiptNbr, Equal <POReceipt.receiptNbr> >, InnerJoin <SOLine, On <SOLine.pOType, Equal <POReceiptLine.pOType>, And <SOLine.pONbr, Equal <POReceiptLine.pONbr>, And <SOLine.pOLineNbr, Equal <POReceiptLine.pOLineNbr>, And <SOLine.orderType, Equal <SOOrder.orderType>, And <SOLine.orderNbr, Equal <SOOrder.orderNbr> > > > > >, LeftJoin <ARTran, On <ARTran.sOShipmentNbr, Equal <POReceiptLine.receiptNbr>, And <ARTran.sOShipmentType, Equal <SOShipmentType.dropShip>, And <ARTran.sOShipmentLineNbr, Equal <POReceiptLine.lineNbr>, And <ARTran.sOOrderType, Equal <SOLine.orderType>, And <ARTran.sOOrderNbr, Equal <SOLine.orderNbr>, And <ARTran.sOOrderLineNbr, Equal <SOLine.lineNbr> > > > > > >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOLine.orderType> >, InnerJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType, Equal <SOOrder.orderType>, And <SOOrderTypeOperation.operation, Equal <SOLine.operation> > > > > > > > >, Where <POReceipt.released, Equal <boolTrue>, And2 <Where <POReceiptLine.lineType, Equal <POLineType.goodsForDropShip>, Or <POReceiptLine.lineType, Equal <POLineType.nonStockForDropShip> > >, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>, And <ARTran.refNbr, IsNull> > > >, Aggregate <GroupBy <POReceipt.receiptNbr, GroupBy <POReceipt.createdByID, GroupBy <POReceipt.lastModifiedByID, GroupBy <POReceipt.released, GroupBy <POReceipt.ownerID, GroupBy <POReceipt.hold> > > > > > > >(this); break; case "9": cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > > > > > >, Where <SOShipment.labelsPrinted, Equal <False>, And <Match <INSite, Current <AccessInfo.userName> > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; default: cmd = new PXSelectJoinGroupBy <SOShipment, LeftJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, InnerJoin <INSite, On <INSite.siteID, Equal <SOShipment.siteID> >, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > > > > > >, Where <Match <INSite, Current <AccessInfo.userName> > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; } if (typeof(PXSelectBase <SOShipment>).IsAssignableFrom(cmd.GetType())) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, LessEqual <Current <SOShipmentFilter.endDate> > > >(); if (filter.SiteID != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.siteID, Equal <Current <SOShipmentFilter.siteID> > > >(); } if (!string.IsNullOrEmpty(filter.CarrierPluginID)) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >(); } if (!string.IsNullOrEmpty(filter.ShipVia)) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >(); } if (filter.StartDate != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >(); } if (filter.CustomerID != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >(); } if (actionID == "7" && filter.ShowPrinted == false) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.labelsPrinted, Equal <False> > >(); } if (filter.PackagingType == SOShipmentFilter.Manual) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, Equal <True> > >(); } else if (filter.PackagingType == SOShipmentFilter.Auto) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOOrder.isManualPackage, NotEqual <True> > >(); } int startRow = PXView.StartRow; int totalRows = 0; foreach (object res in ((PXSelectBase <SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows)) { SOShipment order = PXResult.Unwrap <SOShipment>(res); SOOrder so = PXResult.Unwrap <SOOrder>(res); if (order.BilledOrderCntr + order.UnbilledOrderCntr + order.ReleasedOrderCntr == 1) { order.CustomerOrderNbr = so.CustomerOrderNbr; } object item; if ((item = (SOShipment)Orders.Cache.Locate(order)) == null || Orders.Cache.GetStatus(item) == PXEntryStatus.Notchanged) { yield return(order); } } PXView.StartRow = 0; } if (typeof(PXSelectBase <POReceipt>).IsAssignableFrom(cmd.GetType())) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, LessEqual <Current <SOShipmentFilter.endDate> > > >(); /* * if (filter.SiteID != null) * { * ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.siteID, Equal<Current<SOShipmentFilter.siteID>>>>(); * } * * if (!string.IsNullOrEmpty(filter.ShipVia)) * { * ((PXSelectBase<POReceipt>)cmd).WhereAnd<Where<POReceipt.shipVia, Equal<Current<SOShipmentFilter.shipVia>>>>(); * } */ if (filter.StartDate != null) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >(); } foreach (PXResult <POReceipt, SOOrder> res in ((PXSelectBase <POReceipt>)cmd).Select()) { SOShipment order = res; if ((order = (SOShipment)Orders.Cache.Locate(order)) == null) { Orders.Cache.SetStatus(order = res, PXEntryStatus.Held); yield return(order); } else if (Orders.Cache.GetStatus(order) == PXEntryStatus.Notchanged || Orders.Cache.GetStatus(order) == PXEntryStatus.Held) { yield return(order); } } } Orders.Cache.IsDirty = false; }
void IPrefetchable <DefinitionParams> .Prefetch(DefinitionParams parameters) { try { PXContext.SetSlot <bool>(PXSelectorAttribute.selectorBypassInit, true); List <object> attributes = new List <object>(); List <string> distinct = new List <string>(); PXView view = null; IBqlSearch srch = null; if (parameters.Selector == null) { PXFieldState state = parameters.Foreign.GetStateExt(null, parameters.Field.Name) as PXFieldState; if (state != null && !String.IsNullOrEmpty(state.ViewName)) { view = parameters.Main.Graph.Views[state.ViewName]; srch = view.BqlSelect as IBqlSearch; } } else { view = new PXView(parameters.Main.Graph, true, parameters.Selector); srch = view.BqlSelect as IBqlSearch; } if (srch != null) { if (!view.AllowSelect) { throw new PXException(ErrorMessages.NotEnoughRightsToAccessObject, view.GetItemType().Name); } object current = parameters.Main.CreateInstance(); foreach (object res in view.SelectMultiBound(new object[] { current })) { object attr = (res is PXResult ? ((PXResult)res)[0] : res); if (attr != null) { string name = view.Cache.GetValue(attr, srch.GetField().Name) as string; if (!String.IsNullOrEmpty(name) && !distinct.Contains(name)) { distinct.Add(name); attributes.Add(attr); } } } // Creating empty graph to get original field state without overridden attributes on CacheAttached in parameters.Main.Graph PXGraph independentGraph = PXGraph.CreateInstance <AttrGraph>(); PXCache independentCache = independentGraph.Caches[parameters.Main.GetItemType()]; foreach (IBqlParameter par in view.BqlSelect.GetParameters()) { if (par.HasDefault && par.GetReferencedType().IsNested&& BqlCommand.GetItemType(par.GetReferencedType()).IsAssignableFrom(parameters.Main.GetItemType())) { PXFieldState state = independentCache.GetStateExt(null, par.GetReferencedType().Name) as PXFieldState; // graph-independent state if (state != null && !String.IsNullOrEmpty(state.ViewName)) { PXView parview = independentGraph.Views[state.ViewName]; List <object> pars = new List <object>(); IBqlSearch parsrch = parview.BqlSelect as IBqlSearch; if (parsrch != null) { foreach (object res in parview.SelectMultiBound(new object[] { current })) { object item = res; if (item is PXResult) { item = PXResult.Unwrap(item, parview.Cache.GetItemType()); } if (item is PXFieldState) { item = PXFieldState.UnwrapValue(item); } object cls = parview.Cache.GetValue(item, parsrch.GetField().Name); if (cls != null) { parameters.Main.SetValue(current, par.GetReferencedType().Name, cls); foreach (object parres in view.SelectMultiBound(new object[] { current })) { object attr = (parres is PXResult ? ((PXResult)parres)[0] : parres); if (attr != null) { string name = view.Cache.GetValue(attr, srch.GetField().Name) as string; if (!String.IsNullOrEmpty(name) && !distinct.Contains(name)) { distinct.Add(name); attributes.Add(attr); } } } } } } } break; } } } List <PXFieldState> fields = new List <PXFieldState>(); foreach (object attr in attributes) { var fs = CreateFieldState(((string)view.Cache.GetValue(attr, srch.GetField().Name)) + '_' + parameters.FieldName, (string)view.Cache.GetValue(attr, parameters.DescriptionField), (int)view.Cache.GetValue(attr, parameters.ControlTypeField), (string)view.Cache.GetValue(attr, parameters.EntryMaskField), (string)view.Cache.GetValue(attr, parameters.ListField)); if (fs != null) { fields.Add(fs); } } Fields = fields.ToArray(); } finally { PXContext.SetSlot <bool>(PXSelectorAttribute.selectorBypassInit, false); } }
private static void ProcessValidation(ValidationFilter filter, Contact record) { BusinessAccountMaint graph = PXGraph.CreateInstance <BusinessAccountMaint>(); PXView view = graph.BAccount.View; int startRow = 0, totalRows = 0; BAccount baccount = null; Contact contact = null; if (record.ContactType == ContactTypesAttribute.BAccountProperty && record.BAccountID != null) { List <object> list_baccount = view.Select(null, null, new object[] { record.BAccountID }, new string[] { typeof(BAccount.bAccountID).Name }, null, null, ref startRow, 1, ref totalRows); if (list_baccount != null && list_baccount.Count >= 1) { baccount = PXResult.Unwrap <BAccount>(list_baccount[0]); } } if (baccount == null || baccount.DefContactID != record.ContactID) { throw new PXException(Messages.ContactNotFound); } contact = graph.DefContact.Current = graph.DefContact.SelectWindowed(0, 1); contact.DuplicateFound = true; PXView viewDuplicates = graph.Duplicates.View; if (viewDuplicates == null) { throw new PXException(Messages.DuplicateViewNotFound); } viewDuplicates.Clear(); List <object> duplicates = viewDuplicates.SelectMulti(); contact = (Contact)graph.DefContact.Cache.CreateCopy(contact); contact.DuplicateStatus = DuplicateStatusAttribute.Validated; Decimal?score = 0; foreach (PXResult <CRDuplicateRecord, Contact, CRLeadContactValidationProcess.Contact2> r in duplicates) { CRLeadContactValidationProcess.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; } } } graph.DefContact.Cache.Update(contact); graph.DefContact.Cache.RestoreCopy(record, contact); graph.Actions.PressSave(); }
public virtual IEnumerable orders() { PXUIFieldAttribute.SetDisplayName <SOShipment.customerID>(Caches[typeof(SOShipment)], Messages.CustomerID); SOShipmentFilter filter = Filter.Current; int?action = GetActionIDByName(filter.Action); if (action == null) { yield break; } if (_ActionChanged) { Orders.Cache.Clear(); } PXSelectBase cmd; switch (action) { case SOShipmentEntryActionsAttribute.CreateInvoice: cmd = new PXSelectJoin <SOShipment, InnerJoin <INSite, On <SOShipment.FK.Site>, InnerJoinSingleTable <Customer, On <SOShipment.customerID, Equal <Customer.bAccountID> >, LeftJoin <Carrier, On <SOShipment.FK.Carrier> > > >, Where <SOShipment.confirmed, Equal <boolTrue>, And2 <Match <Customer, Current <AccessInfo.userName> >, And2 <Match <INSite, Current <AccessInfo.userName> >, And <Exists < Select <SOOrderShipment, Where <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.invoiceNbr, IsNull, And <SOOrderShipment.createARDoc, Equal <True> > > > > > > > > > > >(this); break; case SOShipmentEntryActionsAttribute.PostInvoiceToIN: cmd = new PXSelectJoin <SOShipment, InnerJoin <INSite, On <SOShipment.FK.Site>, LeftJoinSingleTable <Customer, On <SOShipment.customerID, Equal <Customer.bAccountID> >, LeftJoin <Carrier, On <SOShipment.FK.Carrier> > > >, Where <SOShipment.confirmed, Equal <boolTrue>, And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >, And2 <Match <INSite, Current <AccessInfo.userName> >, And <Exists < Select <SOOrderShipment, Where <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.invtRefNbr, IsNull, And <SOOrderShipment.createINDoc, Equal <True> > > > > > > > > > > >(this); break; case SOShipmentEntryActionsAttribute.CreateDropshipInvoice: cmd = new PXSelectJoinGroupBy <POReceipt, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentNbr, Equal <POReceipt.receiptNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipmentType.dropShip> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >, InnerJoin <SOOrderType, On <SOOrderType.orderType, Equal <SOOrderShipment.orderType> >, InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > >, Where <POReceipt.released, Equal <True>, //And2<Where<POReceiptLine.lineType, Equal<POLineType.goodsForDropShip>, Or<POReceiptLine.lineType, Equal<POLineType.nonStockForDropShip>>>, And <SOOrderType.aRDocType, NotEqual <ARDocType.noUpdate>, And <SOOrderShipment.invoiceNbr, IsNull, And <Match <Customer, Current <AccessInfo.userName> > > > > >, Aggregate <GroupBy <POReceipt.receiptNbr, GroupBy <POReceipt.createdByID, GroupBy <POReceipt.lastModifiedByID, GroupBy <POReceipt.released, GroupBy <POReceipt.ownerID, GroupBy <POReceipt.hold> > > > > > > >(this); break; case SOShipmentEntryActionsAttribute.CancelReturn: cmd = new PXSelectJoinGroupBy <SOShipment, InnerJoin <INSite, On <SOShipment.FK.Site>, LeftJoin <Carrier, On <SOShipment.FK.Carrier>, InnerJoin <SOOrderShipment, On <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType>, And <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr> > >, InnerJoin <SOOrder, On <SOOrder.orderType, Equal <SOOrderShipment.orderType>, And <SOOrder.orderNbr, Equal <SOOrderShipment.orderNbr> > >, InnerJoinSingleTable <Customer, On <SOOrder.customerID, Equal <Customer.bAccountID> > > > > > >, Where <SOShipment.labelsPrinted, Equal <False>, And2 <Match <Customer, Current <AccessInfo.userName> >, And <Match <INSite, Current <AccessInfo.userName> > > > >, Aggregate <GroupBy <SOShipment.shipmentNbr, GroupBy <SOShipment.createdByID, GroupBy <SOShipment.lastModifiedByID, GroupBy <SOShipment.confirmed, GroupBy <SOShipment.ownerID, GroupBy <SOShipment.released, GroupBy <SOShipment.hold, GroupBy <SOShipment.resedential, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.groundCollect, GroupBy <SOShipment.saturdayDelivery, GroupBy <SOShipment.shippedViaCarrier, GroupBy <SOShipment.labelsPrinted> > > > > > > > > > > > > > >(this); break; default: cmd = new PXSelectJoin <SOShipment, InnerJoin <INSite, On <SOShipment.FK.Site>, LeftJoinSingleTable <Customer, On <SOShipment.customerID, Equal <Customer.bAccountID> >, LeftJoin <Carrier, On <SOShipment.FK.Carrier> > > >, Where2 <Match <INSite, Current <AccessInfo.userName> >, And2 <Where <Customer.bAccountID, IsNull, Or <Match <Customer, Current <AccessInfo.userName> > > >, And <Exists < Select <SOOrderShipment, Where <SOOrderShipment.shipmentNbr, Equal <SOShipment.shipmentNbr>, And <SOOrderShipment.shipmentType, Equal <SOShipment.shipmentType> > > > > > > > >(this); break; } if (typeof(PXSelectBase <SOShipment>).IsAssignableFrom(cmd.GetType())) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, LessEqual <Current <SOShipmentFilter.endDate> > > >(); if (filter.SiteID != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.siteID, Equal <Current <SOShipmentFilter.siteID> > > >(); } if (!string.IsNullOrEmpty(filter.CarrierPluginID)) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >(); } if (!string.IsNullOrEmpty(filter.ShipVia)) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >(); } if (filter.StartDate != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.shipDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >(); } if (filter.CustomerID != null) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >(); } if (action == SOShipmentEntryActionsAttribute.PrintLabels && filter.ShowPrinted == false) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.labelsPrinted, Equal <False> > >(); } if (action == SOShipmentEntryActionsAttribute.PrintPickList && filter.ShowPrinted == false) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.pickListPrinted, Equal <False> > >(); } if (filter.PackagingType == SOPackageType.ForFiltering.Manual) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.isManualPackage, Equal <True> > >(); } else if (filter.PackagingType == SOPackageType.ForFiltering.Auto) { ((PXSelectBase <SOShipment>)cmd).WhereAnd <Where <SOShipment.isManualPackage, Equal <False> > >(); } int startRow = PXView.StartRow; int totalRows = 0; foreach (object res in ((PXSelectBase <SOShipment>)cmd).View.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows)) { SOShipment shipment = PXResult.Unwrap <SOShipment>(res); SOShipment cached = (SOShipment)Orders.Cache.Locate(shipment); if (cached != null) { shipment.Selected = cached.Selected; shipment.BillSeparately = cached.BillSeparately; } yield return(shipment); } PXView.StartRow = 0; } if (typeof(PXSelectBase <POReceipt>).IsAssignableFrom(cmd.GetType())) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, LessEqual <Current <SOShipmentFilter.endDate> > > >(); if (filter.CustomerID != null) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <SOOrderShipment.customerID, Equal <Current <SOShipmentFilter.customerID> > > >(); } if (filter.ShipVia != null) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <SOOrder.shipVia, Equal <Current <SOShipmentFilter.shipVia> > > >(); } if (filter.CarrierPluginID != null) { ((PXSelectBase <POReceipt>)cmd).Join <InnerJoin <Carrier, On <Carrier.carrierID, Equal <SOOrder.shipVia> > > >(); ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <Carrier.carrierPluginID, Equal <Current <SOShipmentFilter.carrierPluginID> > > >(); } if (filter.StartDate != null) { ((PXSelectBase <POReceipt>)cmd).WhereAnd <Where <POReceipt.receiptDate, GreaterEqual <Current <SOShipmentFilter.startDate> > > >(); } foreach (PXResult <POReceipt, SOOrderShipment, SOOrder> res in ((PXSelectBase <POReceipt>)cmd).Select()) { SOShipment order = res; SOShipment cached = (SOShipment)Orders.Cache.Locate(order); if (cached == null) { Orders.Cache.SetStatus(order, PXEntryStatus.Held); } else { order.Selected = cached.Selected; order.BillSeparately = cached.BillSeparately; } yield return(order); } } Orders.Cache.IsDirty = false; }
protected new virtual IEnumerable Cancel(PXAdapter a) { if (a.Searches.Length == 1) { PXResult <SOOrderType> orderType = PXSelectJoin <SOOrderType, LeftJoin <SOOrderTypeOperation, On2 <SOOrderTypeOperation.FK.OrderType, And <SOOrderTypeOperation.operation, Equal <SOOrderType.defaultOperation> > > >, Where <SOOrderType.requireShipping, Equal <boolFalse>, Or <FeatureInstalled <FeaturesSet.inventory> > > > .Search <SOOrderType.orderType>(this, a.Searches[0]); if (orderType != null && (!soordertype.View.BqlSelect.Meet(soordertype.Cache, (SOOrderType)orderType) || !soordertype.View.BqlSelect.Meet(operations.Cache, PXResult.Unwrap <SOOrderTypeOperation>(orderType)))) { a.Searches[0] = null; } } return((new PXCancel <SOOrderType>(this, "Cancel")).Press(a)); }
public static bool DefaultBLOCContact <TContact, TContactID>(PXCache sender, string fieldName, object documentRow, object contactRow, object sourceRow) where TContact : class, IBqlTable, IContact, new() where TContactID : IBqlField { bool contactFound = false; if (sourceRow != null) { FSContact contact = contactRow as FSContact; if (contact == null) { contact = PXSelect <FSContact, Where < FSContact.contactID, Equal <Required <TContactID> > > > .Select(sender.Graph, sender.GetValue(documentRow, fieldName)); } if (PXResult.Unwrap <FSContact>(sourceRow)?.ContactID == null || sender.GetValue(documentRow, fieldName) == null) { if (contact == null || contact.ContactID > 0) { contact = new FSContact(); } contact.BAccountContactID = PXResult.Unwrap <TContact>(sourceRow).ContactID; contact.BAccountID = PXResult.Unwrap <TContact>(sourceRow).BAccountID; contact.RevisionID = PXResult.Unwrap <TContact>(sourceRow).RevisionID; contact.IsDefaultContact = true; contact.FullName = PXResult.Unwrap <TContact>(sourceRow).FullName; contact.Salutation = PXResult.Unwrap <TContact>(sourceRow).Salutation; contact.Attention = PXResult.Unwrap <TContact>(sourceRow).Attention; contact.Title = PXResult.Unwrap <TContact>(sourceRow).Title; contact.Phone1 = PXResult.Unwrap <TContact>(sourceRow).Phone1; contact.Phone1Type = PXResult.Unwrap <TContact>(sourceRow).Phone1Type; contact.Phone2 = PXResult.Unwrap <TContact>(sourceRow).Phone2; contact.Phone2Type = PXResult.Unwrap <TContact>(sourceRow).Phone2Type; contact.Phone3 = PXResult.Unwrap <TContact>(sourceRow).Phone3; contact.Phone3Type = PXResult.Unwrap <TContact>(sourceRow).Phone3Type; contact.Fax = PXResult.Unwrap <TContact>(sourceRow).Fax; contact.FaxType = PXResult.Unwrap <TContact>(sourceRow).FaxType; contact.Email = PXResult.Unwrap <TContact>(sourceRow).Email; contactFound = contact.BAccountContactID != null && contact.BAccountID != null && contact.RevisionID != null; if (contact.ContactID == null) { contact = (FSContact)sender.Graph.Caches[typeof(FSContact)].Insert(contact); sender.SetValue(documentRow, fieldName, contact.ContactID); } else if (contactRow == null) { sender.Graph.Caches[typeof(FSContact)].Update(contact); } } else { if (contact != null && contact.ContactID < 0) { sender.Graph.Caches[typeof(FSContact)].Delete(contact); } sender.SetValue(documentRow, fieldName, PXResult.Unwrap <TContact>(sourceRow).ContactID); contactFound = PXResult.Unwrap <FSContact>(sourceRow).ContactID != null; } } return(contactFound); }
protected new virtual IEnumerable Cancel(PXAdapter a) { if (a.Searches.Length == 1) { PXResult <SOOrderType> orderType = PXSelectJoin <SOOrderType, LeftJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType, Equal <SOOrderType.orderType>, And <SOOrderTypeOperation.operation, Equal <SOOrderType.defaultOperation> > > > > .Search <SOOrderType.orderType>(this, a.Searches[0]); if (orderType != null && (!soordertype.View.BqlSelect.Meet(soordertype.Cache, (SOOrderType)orderType) || !soordertype.View.BqlSelect.Meet(operations.Cache, PXResult.Unwrap <SOOrderTypeOperation>(orderType)))) { a.Searches[0] = null; } } return((new PXCancel <SOOrderType>(this, "Cancel")).Press(a)); }
public static bool DefaultBLOCAddress <TAddress, TAddressID>(PXCache sender, string fieldName, object documentRow, object addressRow, object sourceRow) where TAddress : class, IBqlTable, IAddress, new() where TAddressID : IBqlField { bool addressFound = false; if (sourceRow != null) { FSAddress address = addressRow as FSAddress; if (address == null) { address = PXSelect <FSAddress, Where < FSAddress.addressID, Equal <Required <TAddressID> > > > .Select(sender.Graph, sender.GetValue(documentRow, fieldName)); } if (PXResult.Unwrap <FSAddress>(sourceRow)?.AddressID == null || sender.GetValue(documentRow, fieldName) == null) { if (address == null || address.AddressID > 0) { address = new FSAddress(); } address.BAccountAddressID = PXResult.Unwrap <TAddress>(sourceRow).AddressID; address.BAccountID = PXResult.Unwrap <TAddress>(sourceRow).BAccountID; address.RevisionID = PXResult.Unwrap <TAddress>(sourceRow).RevisionID; address.IsDefaultAddress = true; address.AddressLine1 = PXResult.Unwrap <TAddress>(sourceRow).AddressLine1; address.AddressLine2 = PXResult.Unwrap <TAddress>(sourceRow).AddressLine2; address.AddressLine3 = PXResult.Unwrap <TAddress>(sourceRow).AddressLine3; address.City = PXResult.Unwrap <TAddress>(sourceRow).City; address.State = PXResult.Unwrap <TAddress>(sourceRow).State; address.PostalCode = PXResult.Unwrap <TAddress>(sourceRow).PostalCode; address.CountryID = PXResult.Unwrap <TAddress>(sourceRow).CountryID; address.IsValidated = PXResult.Unwrap <TAddress>(sourceRow).IsValidated; addressFound = address.BAccountAddressID != null && address.BAccountID != null && address.RevisionID != null; if (address.AddressID == null) { address = (FSAddress)sender.Graph.Caches[typeof(FSAddress)].Insert(address); sender.SetValue(documentRow, fieldName, address.AddressID); } else if (addressRow == null) { sender.Graph.Caches[typeof(FSAddress)].Update(address); } } else { if (address != null && address.AddressID < 0) { sender.Graph.Caches[typeof(FSAddress)].Delete(address); } sender.SetValue(documentRow, fieldName, PXResult.Unwrap <TAddress>(sourceRow).AddressID); addressFound = PXResult.Unwrap <FSAddress>(sourceRow).AddressID != null; } } return(addressFound); }
protected override TaxDetail CalculateTaxSum(PXCache sender, object taxrow, object row) { TaxRev taxrev = PXResult.Unwrap <TaxRev>(taxrow); Tax tax = PXResult.Unwrap <Tax>(taxrow); bool propagateCustomRate = false; decimal? origTaxRate = taxrev.TaxRate; SOTaxTran soTax = PXResult <SOTaxTran> .Current; if (taxrev != null && taxrev.TaxID != null && tax != null) { KCTaxExt taxExt = tax.GetExtension <KCTaxExt>(); if (taxExt.UsrKCPropagateTaxAmt == true) { if (soTax != null && taxrev.TaxID == soTax.TaxID && soTax.CuryTaxableAmt.GetValueOrDefault() > 0) { decimal?taxRate = soTax.CuryTaxAmt / soTax.CuryTaxableAmt * 100; if (taxRate != origTaxRate && taxRate > 0) { taxrev.TaxRate = taxRate; propagateCustomRate = true; } } } } bool compositeExists = false; foreach (var line in sender.Inserted) { ARTran tran = (ARTran)line; KCSOInvoiceEntryExt graphKCExt = sender.Graph.GetExtension <KCSOInvoiceEntryExt>(); InventoryItem product = graphKCExt.KCInventoryItem.SelectSingle(tran.InventoryID); if (product == null) { continue; } InventoryItemPCExt productPCExt = product.GetExtension <InventoryItemPCExt>(); if (productPCExt == null) { continue; } if (productPCExt.UsrKNCompositeType != null) { compositeExists = true; tran.CuryTranAmt = 0; tran.TranAmt = 0; } } TaxDetail result = base.CalculateTaxSum(sender, taxrow, row); if ((compositeExists || result == null) && PXResult <SOOrder> .Current != null && soTax != null) { if (result != null) { result = null; } bool?isFromCA = ((SOOrder)PXResult <SOOrder> .Current).GetExtension <KCSOOrderExt>().UsrKCSiteName?.EndsWith("FBA"); if (isFromCA.GetValueOrDefault()) { decimal?taxableAmount = 0; foreach (ARTran tran in sender.Inserted) { if (tran.LineType == KCConstants.LineTypeGI || tran.LineType == KCConstants.LineTypeGN) { taxableAmount += tran.TranAmt; } } if (soTax.CuryTaxableAmt != soTax.TaxableAmt && soTax.CuryTaxableAmt == 0) { soTax.CuryTaxableAmt = soTax.TaxableAmt; } decimal?taxAmount = soTax.TaxAmt * taxableAmount / soTax.CuryTaxableAmt; result = (TaxDetail)((PXResult)taxrow)[0]; PXCache pxcache2 = sender.Graph.Caches[this._TaxSumType]; pxcache2.SetValue(result, this._CuryOrigTaxableAmt, soTax.CuryTaxableAmt); pxcache2.SetValue(result, this._CuryTaxableAmt, taxableAmount); pxcache2.SetValue(result, this._CuryTaxAmt, taxAmount); } } if (propagateCustomRate && result != null) { result.TaxRate = origTaxRate; } return(result); }
public List <PXResult <INItemPlan, INPlanType> > ProcessPOReceipt(PXGraph graph, IEnumerable <PXResult <INItemPlan, INPlanType> > list, string POReceiptType, string POReceiptNbr) { var serviceOrder = new PXSelect <FSServiceOrder>(graph); if (!graph.Views.Caches.Contains(typeof(FSServiceOrder))) { graph.Views.Caches.Add(typeof(FSServiceOrder)); } var soDetSplit = new PXSelect <FSSODetSplit>(graph); if (!graph.Views.Caches.Contains(typeof(FSSODetSplit))) { graph.Views.Caches.Add(typeof(FSSODetSplit)); } var initemplan = new PXSelect <INItemPlan>(graph); List <PXResult <INItemPlan, INPlanType> > returnList = new List <PXResult <INItemPlan, INPlanType> >(); Base.FieldVerifying.AddHandler <FSSODetSplit.lotSerialNbr>((PXCache sender, PXFieldVerifyingEventArgs e) => { e.Cancel = true; }); List <FSSODetSplit> splitsToDeletePlanID = new List <FSSODetSplit>(); List <FSSODetSplit> insertedSchedules = new List <FSSODetSplit>(); List <INItemPlan> deletedPlans = new List <INItemPlan>(); foreach (PXResult <INItemPlan, INPlanType> res in list) { bool includeInReturnList = true; INItemPlan plan = PXCache <INItemPlan> .CreateCopy(res); INPlanType plantype = res; //avoid ReadItem() if (initemplan.Cache.GetStatus(plan) != PXEntryStatus.Inserted) { initemplan.Cache.SetStatus(plan, PXEntryStatus.Notchanged); } //Original Schedule Marked for PO / Allocated on Remote Whse //FSSODetSplit schedule = PXSelect<FSSODetSplit, Where<FSSODetSplit.planID, Equal<Required<FSSODetSplit.planID>>, And<FSSODetSplit.completed, Equal<False>>>>.Select(this, plan.DemandPlanID); FSSODetSplit schedule = PXSelect <FSSODetSplit, Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> > > > .Select(graph, plan.DemandPlanID); if (schedule != null && (schedule.Completed == false || soDetSplit.Cache.GetStatus(schedule) == PXEntryStatus.Updated)) { includeInReturnList = false; schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); schedule.BaseReceivedQty += plan.PlanQty; schedule.ReceivedQty = INUnitAttribute.ConvertFromBase(soDetSplit.Cache, schedule.InventoryID, schedule.UOM, (decimal)schedule.BaseReceivedQty, INPrecision.QUANTITY); soDetSplit.Cache.Update(schedule); INItemPlan origplan = PXSelect <INItemPlan, Where <INItemPlan.planID, Equal <Required <INItemPlan.planID> > > > .Select(graph, plan.DemandPlanID); if (origplan != null) { origplan.PlanQty = schedule.BaseQty - schedule.BaseReceivedQty; initemplan.Cache.Update(origplan); } //select Allocated line if any, exclude allocated on Remote Whse PXSelectBase <INItemPlan> cmd = new PXSelectJoin <INItemPlan, InnerJoin <FSSODetSplit, On <FSSODetSplit.planID, Equal <INItemPlan.planID> > >, Where <INItemPlan.demandPlanID, Equal <Required <INItemPlan.demandPlanID> >, And <FSSODetSplit.isAllocated, Equal <True>, And <FSSODetSplit.siteID, Equal <Required <FSSODetSplit.siteID> > > > > >(graph); if (!string.IsNullOrEmpty(plan.LotSerialNbr)) { cmd.WhereAnd <Where <INItemPlan.lotSerialNbr, Equal <Required <INItemPlan.lotSerialNbr> > > >(); } PXResult <INItemPlan> allocres = cmd.Select(plan.DemandPlanID, plan.SiteID, plan.LotSerialNbr); if (allocres != null) { schedule = PXResult.Unwrap <FSSODetSplit>(allocres); soDetSplit.Cache.SetStatus(schedule, PXEntryStatus.Notchanged); schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); schedule.BaseQty += plan.PlanQty; schedule.Qty = INUnitAttribute.ConvertFromBase(soDetSplit.Cache, schedule.InventoryID, schedule.UOM, (decimal)schedule.BaseQty, INPrecision.QUANTITY); schedule.POReceiptType = POReceiptType; schedule.POReceiptNbr = POReceiptNbr; soDetSplit.Cache.Update(schedule); INItemPlan allocplan = PXCache <INItemPlan> .CreateCopy(res); allocplan.PlanQty += plan.PlanQty; initemplan.Cache.Update(allocplan); plantype = PXCache <INPlanType> .CreateCopy(plantype); plantype.ReplanOnEvent = null; plantype.DeleteOnEvent = true; } else { serviceOrder.Current = (FSServiceOrder)PXParentAttribute.SelectParent(soDetSplit.Cache, schedule, typeof(FSServiceOrder)); schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); long?oldPlanID = schedule.PlanID; ClearScheduleReferences(ref schedule); plantype.ReplanOnEvent = INPlanConstants.PlanF1; schedule.IsAllocated = false; schedule.LotSerialNbr = plan.LotSerialNbr; schedule.POCreate = false; schedule.POSource = null; schedule.POReceiptType = POReceiptType; schedule.POReceiptNbr = POReceiptNbr; schedule.SiteID = plan.SiteID; schedule.VendorID = null; schedule.BaseReceivedQty = 0m; schedule.ReceivedQty = 0m; schedule.BaseQty = plan.PlanQty; schedule.Qty = INUnitAttribute.ConvertFromBase(soDetSplit.Cache, schedule.InventoryID, schedule.UOM, (decimal)schedule.BaseQty, INPrecision.QUANTITY); //update SupplyPlanID in existing item plans (replenishment) foreach (PXResult <INItemPlan> demand_res in PXSelect <INItemPlan, Where <INItemPlan.supplyPlanID, Equal <Required <INItemPlan.supplyPlanID> > > > .Select(graph, oldPlanID)) { INItemPlan demand_plan = PXCache <INItemPlan> .CreateCopy(demand_res); initemplan.Cache.SetStatus(demand_plan, PXEntryStatus.Notchanged); demand_plan.SupplyPlanID = plan.PlanID; initemplan.Cache.Update(demand_plan); } schedule.PlanID = plan.PlanID; schedule = (FSSODetSplit)soDetSplit.Cache.Insert(schedule); insertedSchedules.Add(schedule); } } else if (plan.DemandPlanID == null) { //Original schedule Marked for PO //TODO: verify this is sufficient for Original SO marked for TR. schedule = PXSelect <FSSODetSplit, Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> >, And <FSSODetSplit.completed, Equal <False> > > > .Select(graph, plan.PlanID); if (schedule != null) { includeInReturnList = false; soDetSplit.Cache.SetStatus(schedule, PXEntryStatus.Notchanged); schedule = PXCache <FSSODetSplit> .CreateCopy(schedule); schedule.Completed = true; schedule.POCompleted = true; splitsToDeletePlanID.Add(schedule); soDetSplit.Cache.Update(schedule); INItemPlan origplan = PXSelect <INItemPlan, Where <INItemPlan.planID, Equal <Required <INItemPlan.planID> > > > .Select(graph, plan.PlanID); deletedPlans.Add(origplan); initemplan.Cache.Delete(origplan); } } if (includeInReturnList == true) { returnList.Add(res); } else { if (plantype.ReplanOnEvent != null) { plan.PlanType = plantype.ReplanOnEvent; plan.SupplyPlanID = null; plan.DemandPlanID = null; initemplan.Cache.Update(plan); } else if (plantype.DeleteOnEvent == true) { initemplan.Delete(plan); } } } //Create new schedules for partially received schedules marked for PO. FSSODetSplit prevSplit = null; foreach (FSSODetSplit newsplit in insertedSchedules) { if (prevSplit != null && prevSplit.SrvOrdType == newsplit.SrvOrdType && prevSplit.RefNbr == newsplit.RefNbr && prevSplit.LineNbr == newsplit.LineNbr && prevSplit.InventoryID == newsplit.InventoryID && prevSplit.SubItemID == newsplit.SubItemID && prevSplit.ParentSplitLineNbr == newsplit.ParentSplitLineNbr && prevSplit.LotSerialNbr != null && newsplit.LotSerialNbr != null) { continue; } FSSODetSplit parentschedule = PXSelect <FSSODetSplit, Where <FSSODetSplit.srvOrdType, Equal <Required <FSSODetSplit.srvOrdType> >, And <FSSODetSplit.refNbr, Equal <Required <FSSODetSplit.refNbr> >, And <FSSODetSplit.lineNbr, Equal <Required <FSSODetSplit.lineNbr> >, And <FSSODetSplit.splitLineNbr, Equal <Required <FSSODetSplit.parentSplitLineNbr> > > > > > > .Select(graph, newsplit.SrvOrdType, newsplit.RefNbr, newsplit.LineNbr, newsplit.ParentSplitLineNbr); if (parentschedule != null && parentschedule.Completed == true && parentschedule.POCompleted == true && parentschedule.BaseQty > parentschedule.BaseReceivedQty && deletedPlans.Exists(x => x.PlanID == parentschedule.PlanID)) { serviceOrder.Current = (FSServiceOrder)PXParentAttribute.SelectParent(soDetSplit.Cache, parentschedule, typeof(FSServiceOrder)); parentschedule = PXCache <FSSODetSplit> .CreateCopy(parentschedule); INItemPlan demand = PXCache <INItemPlan> .CreateCopy(deletedPlans.First(x => x.PlanID == parentschedule.PlanID)); UpdateSchedulesFromCompletedPO(graph, soDetSplit, initemplan, parentschedule, serviceOrder, demand); } prevSplit = newsplit; } //Added because of MySql AutoIncrement counters behavior foreach (FSSODetSplit split in splitsToDeletePlanID) { FSSODetSplit schedule = (FSSODetSplit)soDetSplit.Cache.Locate(split); if (schedule != null) { schedule.PlanID = null; soDetSplit.Cache.Update(schedule); } } return(returnList); }