Esempio n. 1
0
        public static bool FixedAssetHasTransactions(int?assetID, PXGraph graph, string tranType, bool isReleased, string origin = null)
        {
            PXSelectBase <FATran> bql = new PXSelectReadonly <FATran,
                                                              Where <FATran.assetID, Equal <Required <FixedAsset.assetID> >,
                                                                     And <FATran.tranType, Equal <Required <FATran.tranType> > > > >(graph);

            if (isReleased)
            {
                bql.WhereAnd <Where <FATran.released, Equal <True> > >();
            }
            else
            {
                bql.WhereAnd <Where <FATran.released, NotEqual <True> > >();
            }

            if (origin != null)
            {
                bql.WhereAnd <Where <FATran.origin, Equal <Required <FATran.origin> > > >();
                return(bql.SelectSingle(assetID, tranType, origin) != null);
            }
            else
            {
                return(bql.SelectSingle(assetID, tranType) != null);
            }
        }
Esempio n. 2
0
        protected virtual MatrixAttributeValues GetMatrixAttributeValues()
        {
            CSAttributeDetail[] colAttributeValues;
            CSAttributeDetail[] rowAttributeValues;

            var colAttributesSelect = new PXSelectReadonly <CSAttributeDetail,
                                                            Where <CSAttributeDetail.attributeID, Equal <Current <EntryHeader.colAttributeID> > >,
                                                            OrderBy <Asc <CSAttributeDetail.sortOrder> > >(Base);

            if (!ShowDisabledValue)
            {
                colAttributesSelect.WhereAnd <Where <CSAttributeDetail.disabled, Equal <False> > >();
            }

            colAttributeValues = colAttributesSelect.SelectMain();
            var rowAttributesSelect = new PXSelectReadonly <CSAttributeDetail,
                                                            Where <CSAttributeDetail.attributeID, Equal <Current <EntryHeader.rowAttributeID> > >,
                                                            OrderBy <Asc <CSAttributeDetail.sortOrder> > >(Base);

            if (!ShowDisabledValue)
            {
                rowAttributesSelect.WhereAnd <Where <CSAttributeDetail.disabled, Equal <False> > >();
            }

            rowAttributeValues = rowAttributesSelect.SelectMain();

            return(new MatrixAttributeValues()
            {
                ColumnValues = colAttributeValues, RowValues = rowAttributeValues
            });
        }
        public virtual IEnumerable <ApproveInfo> Assign(Table item, EPAssignmentMap map, bool isApprove, int?currentStepSequence)
        {
            path.Clear();

            processMapType = GraphHelper.GetType(map.EntityType);
            Type itemType = item.GetType();

            PXSelectBase <EPRule> rs = new
                                       PXSelectReadonly <
                EPRule,
                Where <
                    EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> > >,
                OrderBy <
                    Asc <EPAssignmentRoute.sequence> > >(this);

            PXResultset <EPRule> rules;

            if (isApprove)
            {
                PXSelectBase <EPRule> ss = new
                                           PXSelectReadonly <
                    EPRule,
                    Where <
                        EPRule.assignmentMapID, Equal <Required <EPAssignmentMap.assignmentMapID> >,
                        And <EPRule.sequence, Greater <Required <EPRule.sequence> >,
                             And <EPRule.stepID, IsNull> > >,
                    OrderBy <
                        Asc <EPAssignmentRoute.sequence> > >(this);
                EPRule nextStep = ss.Select(map.AssignmentMapID, currentStepSequence ?? -1);

                if (nextStep == null)
                {
                    yield break;
                }

                rs.WhereAnd <Where <EPRule.stepID, Equal <Required <EPRule.stepID> > > >();
                rules = rs.Select(map.AssignmentMapID, nextStep.RuleID, null);

                rules.ForEach(_ => ((EPRule)_).StepName = nextStep.Name);
            }
            else
            {
                rules = rs.Select(map.AssignmentMapID, null);
            }

            Type mapgraphtype = GraphHelper.GetType(map.GraphType);

            //impossible, but written to support purpose of legacy db states
            if (mapgraphtype == null)
            {
                mapgraphtype = EntityHelper.GetPrimaryGraphType(this, processMapType);
            }

            if (_Graph != null && mapgraphtype.IsAssignableFrom(_Graph.GetType()))
            {
                processGraph = _Graph;
            }
            else
            {
                processGraph = CreateInstance(GraphHelper.GetType(map.GraphType) ?? mapgraphtype);
            }

            if (processGraph != null && processMapType != null)
            {
                if (processMapType.IsAssignableFrom(itemType))
                {
                    processGraph.Caches[itemType].Current = item;
                }
                else if (itemType.IsAssignableFrom(processMapType))
                {
                    object  placed = processGraph.Caches[processMapType].CreateInstance();
                    PXCache cache  = (PXCache)Activator.CreateInstance(typeof(PXCache <>).MakeGenericType(itemType), this);
                    cache.RestoreCopy(placed, item);
                    processGraph.Caches[processMapType].Current = placed;
                }
                else
                {
                    yield break;
                }
            }

            foreach (var approveInfo in ProcessLevel(item, map.AssignmentMapID, rules))
            {
                yield return(approveInfo);
            }
        }
Esempio n. 4
0
        public virtual IEnumerable pOOrderLinesList()
        {
            APInvoice doc          = Base.Document.Current;
            bool      isInvoice    = (doc.DocType == APDocType.Invoice),
                      isPrepayment = (doc.DocType == APDocType.Prepayment);
            var filter             = orderfilter.Current;

            if (doc?.VendorID == null ||
                doc.VendorLocationID == null ||
                !isInvoice && !isPrepayment)
            {
                return(Enumerable.Empty <POLineRS>());
            }

            PXSelectBase <POLineRS> cmd = new PXSelectReadonly <
                POLineRS,
                Where <POLineRS.orderType, NotIn3 <POOrderType.blanket, POOrderType.standardBlanket>,
                       And <POLineRS.cancelled, NotEqual <True>,
                            And <POLineRS.closed, NotEqual <True>,
                                 And <POLineRS.curyID, Equal <Current <APInvoice.curyID> >,
                                      And <POLineRS.status, In3 <POOrderStatus.open, POOrderStatus.completed>,
                                           And <Where <Current <POOrderFilter.orderNbr>, IsNull, Or <POLineRS.orderNbr, Equal <Current <POOrderFilter.orderNbr> > > > > > > > > > >(Base);

            if (isInvoice)
            {
                cmd.WhereAnd <Where <POLineRS.pOAccrualType, Equal <POAccrualType.order> > >();
            }
            else if (isPrepayment)
            {
                cmd.WhereAnd <Where <POLineRS.curyReqPrepaidAmt, Less <POLineRS.curyExtCost> > >();
                cmd.WhereAnd <Where <POLineRS.taxZoneID, Equal <Current <APInvoice.taxZoneID> >, Or <POLineRS.taxZoneID, IsNull, And <Current <APInvoice.taxZoneID>, IsNull> > > >();
            }

            if (Base.APSetup.Current.RequireSingleProjectPerDocument == true)
            {
                cmd.WhereAnd <Where <POLineRS.projectID, Equal <Current <APInvoice.projectID> > > >();
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.vendorRelations>())
            {
                cmd.WhereAnd <Where <POLineRS.vendorID, Equal <Current <APInvoice.suppliedByVendorID> >,
                                     And <POLineRS.vendorLocationID, Equal <Current <APInvoice.suppliedByVendorLocationID> >,
                                          And <POLineRS.payToVendorID, Equal <Current <APInvoice.vendorID> > > > > >();
            }
            else
            {
                cmd.WhereAnd <Where <POLineRS.vendorID, Equal <Current <APInvoice.vendorID> >,
                                     And <POLineRS.vendorLocationID, Equal <Current <APInvoice.vendorLocationID> > > > >();
            }

            if (filter.ShowBilledLines != true)
            {
                cmd.WhereAnd <Where <POLineRS.unbilledQty, Greater <decimal0>,
                                     Or <POLineRS.curyUnbilledAmt, Greater <decimal0> > > >();
            }

            var usedPOAccrual = new Lazy <POAccrualSet>(() => Base.GetUsedPOAccrualSet());

            return(cmd.View.SelectMultiBound(new object[] { doc, filter })
                   .RowCast <POLineRS>().AsEnumerable()
                   .Where(t => !usedPOAccrual.Value.Contains(t))
                   .ToList());
        }