Ejemplo n.º 1
0
        public virtual IEnumerable records(PXAdapter adapter)
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(POPrintOrderFilter),
                typeof(POPrintOrderOwned.workgroupID),
                typeof(POPrintOrderOwned.ownerID));

            Type printWhere =
                typeof(Where <POPrintOrderOwned.hold, Equal <False>,
                              And <POPrintOrderOwned.dontPrint, Equal <False>,
                                   And <POPrintOrderOwned.printed, NotEqual <True> > > >);
            Type emailWhere =
                typeof(Where <POPrintOrderOwned.hold, Equal <False>,
                              And <POPrintOrderOwned.dontEmail, Equal <False>,
                                   And <POPrintOrderOwned.emailed, NotEqual <True> > > >);

            Type action =
                Filter.Current.Action == "<SELECT>"
                                ? typeof(Where <CS.boolTrue, Equal <CS.boolFalse> >)
                                : Filter.Current.Action.Contains("Email")
                                ? emailWhere :
                printWhere;

            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(POPrintOrderOwned),
                    typeof(InnerJoin <Vendor, On <Vendor.bAccountID, Equal <POPrintOrderOwned.vendorID> > >),
                    typeof(Where <>), action);

            PXView view = new PXView(this, false, BqlCommand.CreateInstance(select));

            return(view.SelectMulti());
        }
Ejemplo n.º 2
0
        public static void VerifyFinPeriod <fieldPeriod, fieldClosed>(PXGraph graph, PXCache cache, object row, PXSelectBase <FinPeriod> finperiod)
            where fieldPeriod : class, IBqlField
            where fieldClosed : class, IBqlField
        {
            if (finperiod.Current != null)
            {
                GLSetup glsetup = PXSetup <GLSetup> .Select(graph);

                object isClosed = finperiod.Cache.GetValue <fieldClosed>(finperiod.Current);

                if (finperiod.Current.Active != true || isClosed.Equals(true) && glsetup != null && glsetup.PostClosedPeriods != true)
                {
                    BqlCommand select = BqlCommand.CreateInstance(typeof(Select <FinPeriod,
                                                                                 Where <FinPeriod.active, Equal <True>,
                                                                                        And <FinPeriod.finPeriodID, Greater <Required <FinPeriod.finPeriodID> > > >,
                                                                                 OrderBy <Asc <FinPeriod.finPeriodID> > >))
                                        .WhereAnd(BqlCommand.Compose(typeof(Where <,>), typeof(fieldClosed), typeof(NotEqual <True>)));

                    object    docPeriod = cache.GetValue <fieldPeriod>(row);
                    FinPeriod firstopen = new PXView(graph, false, select).SelectSingle(docPeriod) as FinPeriod;

                    if (firstopen == null)
                    {
                        string userPeriod = Mask.Format("##-####", finperiod.Cache.GetValueExt <FinPeriod.finPeriodID>(finperiod.Current).ToString());
                        throw new PXSetPropertyException(GL.Messages.NoActivePeriodAfter, userPeriod);
                    }

                    cache.SetValue <fieldPeriod>(row, firstopen.FinPeriodID);
                }
            }
        }
        public IsSchedulable()
        {
            Dictionary <string, Type> fields = typeof(TRegister)
                                               .GetNestedTypes()
                                               .ToDictionary(nestedTypes => nestedTypes.Name);

            Type releasedField          = fields[nameof(APRegister.released)];
            Type prebookedField         = fields[nameof(APRegister.prebooked)];
            Type holdField              = fields[nameof(APRegister.hold)];
            Type voidedField            = fields[nameof(APRegister.voided)];
            Type rejectedField          = fields[nameof(APRegister.rejected)];
            Type origModuleField        = fields[nameof(APRegister.origModule)];
            Type isMigratedRecordField  = fields[nameof(APRegister.isMigratedRecord)];
            Type createdByScreenIdField = fields[nameof(APRegister.createdByScreenID)];
            Type docTypeField           = fields[nameof(APRegister.docType)];
            Type refNbrField            = fields[nameof(APRegister.refNbr)];
            Type noteIdField            = fields[nameof(APRegister.noteID)];

            Type whereType = BqlCommand.Compose(
                typeof(Where <, ,>),
                releasedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), prebookedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), holdField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), voidedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), rejectedField, typeof(Equal <>), typeof(False),
                typeof(And <, ,>), origModuleField, typeof(Equal <>), typeof(BatchModule.moduleAP),
                typeof(And <, ,>), isMigratedRecordField, typeof(Equal <>), typeof(False),
                typeof(And2 <,>), typeof(Not <>), typeof(IsPOLinked <,>), docTypeField, refNbrField,
                typeof(And <>), typeof(Not <>), typeof(ExistsJournalVoucher <>), noteIdField);

            where = Activator.CreateInstance(whereType) as IBqlUnary;
        }
            protected override List <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> > SelectInventoryWithAttributes()
            {
                Type sumDecimalFields = BqlCommand.Compose(BqlHelper.GetDecimalFieldsAggregate <INSiteStatus>(Base, true).ToArray());

                Type select = BqlTemplate.OfCommand <
                    Select5 <CSAnswers,
                             InnerJoin <CSAttributeGroup, On <CSAnswers.attributeID, Equal <CSAttributeGroup.attributeID> >,
                                        InnerJoin <InventoryItem, On <CSAnswers.refNoteID, Equal <InventoryItem.noteID>,
                                                                      And <CSAttributeGroup.entityClassID, Equal <InventoryItem.itemClassID> > >,
                                                   LeftJoin <INSiteStatus, On <INSiteStatus.inventoryID, Equal <InventoryItem.inventoryID>,
                                                                               And <INSiteStatus.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                    And <Where <INSiteStatus.siteID, Equal <Current <EntryHeader.siteID> >, Or <Current <EntryHeader.siteID>, IsNull> > > > >,
                                                             LeftJoin <INLocationStatus, On <INLocationStatus.inventoryID, Equal <InventoryItem.inventoryID>,
                                                                                             And <INLocationStatus.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                                  And <INLocationStatus.siteID, Equal <Current <EntryHeader.siteID> >,
                                                                                                       And <INLocationStatus.locationID, Equal <Current <EntryHeader.locationID> > > > > > > > > >,
                             Where <CSAttributeGroup.isActive, Equal <True>,
                                    And <CSAttributeGroup.entityType, Equal <Constants.DACName <InventoryItem> >,
                                         And <CSAttributeGroup.attributeCategory, Equal <CSAttributeGroup.attributeCategory.variant>,
                                              And <InventoryItem.templateItemID, Equal <Current <EntryHeader.templateItemID> > > > > >,
                             Aggregate <GroupBy <InventoryItem.inventoryID, GroupBy <CSAnswers.refNoteID, GroupBy <CSAnswers.attributeID, BqlPlaceholder.A> > > >,
                             OrderBy <Asc <InventoryItem.inventoryID, Asc <CSAnswers.refNoteID, Asc <CSAnswers.attributeID> > > > > >
                              .Replace <BqlPlaceholder.A>(sumDecimalFields)
                              .ToType();

                var view = new PXView(Base, true, BqlCommand.CreateInstance(select));

                using (new PXFieldScope(view,
                                        typeof(InventoryItem.inventoryID), typeof(CSAnswers.attributeID), typeof(CSAnswers.value),
                                        typeof(INSiteStatus), typeof(INLocationStatus)))
                {
                    return(view.SelectMulti().Cast <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> >().ToList());
                }
            }
Ejemplo n.º 5
0
        public CustomerActive2Attribute()
        {
            System.Type type1 = BqlCommand.Compose(typeof(Search2 <, ,>), typeof(BAccountR.bAccountID), typeof(LeftJoin <, ,>), typeof(Customer), typeof(On <Customer.bAccountID, Equal <BAccountR.bAccountID>, And <Match <Customer, Current <AccessInfo.userName> > > >), typeof(LeftJoin <, ,>), typeof(PX.Objects.CR.Contact), typeof(On <PX.Objects.CR.Contact.bAccountID, Equal <BAccountR.bAccountID>, And <PX.Objects.CR.Contact.contactID, Equal <BAccountR.defContactID> > >), typeof(LeftJoin <, ,>), typeof(Address), typeof(On <Address.bAccountID, Equal <BAccountR.bAccountID>, And <Address.addressID, Equal <BAccountR.defAddressID> > >), typeof(LeftJoin <, ,>), typeof(PX.Objects.CR.Location), typeof(On <PX.Objects.CR.Location.bAccountID, Equal <BAccountR.bAccountID>, And <PX.Objects.CR.Location.locationID, Equal <BAccountR.defLocationID> > >), typeof(InnerJoin <,>), typeof(CSAnswers), typeof(On <CSAnswers.refNoteID, Equal <BAccountR.noteID>, And <CSAnswers.attributeID, Equal <FLXProjectEntry.BranchAtt>, And <CSAnswers.value, Contains <RTrim <Current <CustomerExt.usrBranchCD> > > > > >), typeof(Where <BAccountR.type, In3 <BAccountType.branchType, BAccountType.organizationType, BAccountType.customerType, BAccountType.combinedType> >));
            PXAggregateAttribute.AggregatedAttributesCollection attributes = this._Attributes;
            System.Type   type2         = type1;
            System.Type   substituteKey = typeof(BAccountR.acctCD);
            System.Type[] typeArray     = new System.Type[13]
            {
                typeof(BAccountR.acctCD),
                typeof(BAccountR.acctName),
                typeof(Address.addressLine1),
                typeof(Address.addressLine2),
                typeof(Address.postalCode),
                typeof(PX.Objects.CR.Contact.phone1),
                typeof(Address.city),
                typeof(Address.countryID),
                typeof(PX.Objects.CR.Location.taxRegistrationID),
                typeof(Customer.curyID),
                typeof(PX.Objects.CR.Contact.attention),
                typeof(Customer.customerClassID),
                typeof(Customer.status)
            };
            PXDimensionSelectorAttribute selectorAttribute1;
            PXDimensionSelectorAttribute selectorAttribute2 = selectorAttribute1 = new PXDimensionSelectorAttribute("BIZACCT", type2, substituteKey, typeArray);

            attributes.Add((PXEventSubscriberAttribute)selectorAttribute1);
            selectorAttribute2.DescriptionField = typeof(Customer.acctName);
            selectorAttribute2.CacheGlobal      = true;
            selectorAttribute2.FilterEntity     = typeof(Customer);
            this._SelAttrIndex = this._Attributes.Count - 1;
            this.Filterable    = true;
        }
Ejemplo n.º 6
0
 internal static Type ComposeSearchCommand(Type dateField)
 {
     if (!typeof(IBqlField).IsAssignableFrom(dateField))
     {
         throw new PXArgumentException(nameof(dateField));
     }
     return(BqlCommand.Compose(
                typeof(Search <,>),
                typeof(RUTROTWorkType.workTypeID),
                typeof(Where2 <,>),
                typeof(Where <, ,>),
                typeof(RUTROTWorkType.endDate),
                typeof(Greater <>),
                typeof(Current <>),
                dateField,
                typeof(Or <,>),
                typeof(RUTROTWorkType.endDate),
                typeof(IsNull),
                typeof(And <, ,>),
                typeof(RUTROTWorkType.startDate),
                typeof(LessEqual <>),
                typeof(Current <>),
                dateField,
                typeof(And <RUTROTWorkType.rUTROTType, Equal <Current2 <RUTROT.rUTROTType> >, Or <Current2 <RUTROT.rUTROTType>, IsNull> >)));
 }
        protected virtual Type GetBQLStatement()
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(ARTwilioNotificationProcessFilter),
                typeof(ARInvoice.workgroupID),
                typeof(ARInvoice.ownerID));

            Type Where =
                typeof(Where <ARInvoice.hold, Equal <False>,
                              And <ARInvoice.released, Equal <True>,
                                   And <ARInvoice.voided, Equal <False>,
                                        And <ARInvoice.docType, Equal <ARInvoiceType.invoice>,
                                             And <ARInvoice.curyDocBal, Greater <decimal0>,
                                                  And <ARInvoice.docDate, LessEqual <Current <ARTwilioNotificationProcessFilter.endDate> >,
                                                       And <ARInvoice.docDate, GreaterEqual <Current <ARTwilioNotificationProcessFilter.beginDate> > > > > > > > >);

            Type whereAnd;

            whereAnd = Filter.Current.Action == "<SELECT>" ? typeof(Where <True, Equal <False> >) :
                       Where;

            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(ARInvoice),
                    typeof(InnerJoinSingleTable <Customer, On <Customer.bAccountID, Equal <ARInvoice.customerID> > >),
                    typeof(Where2 <,>),
                    typeof(Match <Customer, Current <AccessInfo.userName> >),
                    typeof(And2 <,>), whereAnd,
                    typeof(And <>), where);

            return(select);
        }
 ///
 public PXDBAttributeAttribute(Type valueSearch, Type attributeID)
 {
     if (valueSearch == null)
     {
         throw new PXArgumentException("type", ErrorMessages.ArgumentNullException);
     }
     if (attributeID == null)
     {
         throw new PXArgumentException("field", ErrorMessages.ArgumentNullException);
     }
     _Field = attributeID;
     if (typeof(IBqlSearch).IsAssignableFrom(valueSearch))
     {
         _SingleSelect = BqlCommand.CreateInstance(valueSearch);
     }
     else if (valueSearch.IsNested && typeof(IBqlField).IsAssignableFrom(valueSearch))
     {
         _SingleSelect = BqlCommand.CreateInstance(typeof(Search <>), valueSearch);
     }
     else
     {
         throw new PXArgumentException("valueSearch", ErrorMessages.CantCreateForeignKeyReference, valueSearch);
     }
     _PureWhere    = (_SingleSelect as IHasBqlWhere).GetWhere();
     _SubSelect    = _SingleSelect.WhereAnd(typeof(Where <,>).MakeGenericType(_Field, typeof(Equal <AttributeIDPlaceholder>)));
     _SingleSelect = _SingleSelect.WhereAnd(BqlCommand.Compose(typeof(Where <,>), _Field, typeof(Equal <>), typeof(Required <>), _Field));
 }
Ejemplo n.º 9
0
        private bool IsItemRuleTrue(IBqlTable item, EPAssignmentRule rule)
        {
            if (item is EPEmployee && rule.FieldName.Equals(typeof(EPEmployee.workgroupID).Name, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IsEmployeeInWorkgroup((EPEmployee)item, rule));
            }

            currentItem = item;
            Type   viewType = BqlCommand.Compose(typeof(Select <>), item.GetType());
            PXView itemView = new PXView(this, false, BqlCommand.CreateInstance(viewType),
                                         (PXSelectDelegate)getItemRecord);

            if (rule.Condition == null)
            {
                return(false);
            }

            PXFilterRow filter = new PXFilterRow(
                rule.FieldName,
                (PXCondition)rule.Condition.Value,
                GetFieldValue(item, rule.FieldName, rule.FieldValue),
                null);
            int startRow  = 0;
            int totalRows = 0;

            List <object> result = itemView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows);

            return(result.Count > 0);
        }
 public SOCreateProjectionAttribute()
     : base(typeof(SOCreateFilter),
            BqlCommand.Compose(
                typeof(Select2 <, ,>),
                typeof(INItemPlan),
                typeof(InnerJoin <INPlanType,
                                  On <INPlanType.planType, Equal <INItemPlan.planType> >,
                                  InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <INItemPlan.inventoryID> >,
                                             InnerJoin <INUnit,
                                                        On <INUnit.inventoryID, Equal <InventoryItem.inventoryID>,
                                                            And <INUnit.fromUnit, Equal <InventoryItem.purchaseUnit>,
                                                                 And <INUnit.toUnit, Equal <InventoryItem.baseUnit> > > >,
                                                        LeftJoin <SOLineSplit, On <SOLineSplit.planID, Equal <INItemPlan.planID> >,
                                                                  LeftJoin <IN.S.INItemSite, On <IN.S.INItemSite.inventoryID, Equal <INItemPlan.inventoryID>, And <IN.S.INItemSite.siteID, Equal <INItemPlan.siteID> > > > > > > >),
                typeof(Where2 <,>),
                typeof(Where <INItemPlan.hold, Equal <boolFalse>,
                              And2 <Where <INItemPlan.fixedSource, Equal <INReplenishmentSource.transfer>, Or <INItemPlan.fixedSource, Equal <INReplenishmentSource.transferToPurchase> > >,
                                    And <INItemPlan.supplyPlanID, IsNull> > >),
                typeof(And <>),
                TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                    typeof(SOCreateFilter),
                    typeof(InventoryItem.productWorkgroupID),
                    typeof(InventoryItem.productManagerID))))
 {
 }
Ejemplo n.º 11
0
        private static PXView CreateRestictedIntView(PXGraph graph)
        {
            Type inventoryID = GetTypeField <Status>(typeof(INSiteStatus.inventoryID).Name);
            Type subItemID   = GetTypeField <Status>(typeof(INSiteStatus.subItemID).Name);
            Type siteID      = GetTypeField <Status>(typeof(INSiteStatus.siteID).Name);

            Type join =
                BqlCommand.Compose(
                    typeof(InnerJoin <,>),
                    typeof(RQRequestClassItem),
                    typeof(On <, ,>),
                    typeof(RQRequestClassItem.inventoryID), typeof(Equal <>), inventoryID,
                    typeof(And <RQRequestClassItem.reqClassID, Equal <Current <RQRequestClass.reqClassID> > >));

            Type where = CreateWhere(graph);

            Type selectType =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>),
                    typeof(Status),
                    join,
                    where);

            return(new LookupView(graph, BqlCommand.CreateInstance(selectType)));
        }
        public BranchCDOfOrganizationAttribute(Type organizationFieldType, bool onlyActive = true, Type searchType = null)
        {
            OrganizationFieldType = organizationFieldType;

            Type selectorSource = typeof(Search <Branch.branchCD, Where <MatchWithBranch <Branch.branchID> > >);

            PXDimensionSelectorAttribute attr =
                new PXDimensionSelectorAttribute(_DimensionName, selectorSource)
            {
                ValidComboRequired = true,
                DescriptionField   = typeof(Branch.acctName),
                SelectorMode       = SelectorMode
            };

            _Attributes.Add(attr);

            _Attributes.Add(new PXRestrictorAttribute(BqlCommand.Compose(
                                                          typeof(Where <, ,>),
                                                          typeof(Branch.organizationID), typeof(Equal <>), typeof(Optional2 <>), OrganizationFieldType,
                                                          typeof(Or <,>), typeof(Optional2 <>), OrganizationFieldType, typeof(IsNull)),
                                                      Messages.TheSpecifiedBranchDoesNotBelongToTheSelectedCompany));
            if (onlyActive)
            {
                _Attributes.Add(new PXRestrictorAttribute(typeof(Where <Branch.active, Equal <True> >), Messages.BranchInactive));
            }

            Initialize();
        }
Ejemplo n.º 13
0
        public FABookPeriodIDAttribute(Type BookType, Type SourceType)
            : base(SourceType, BqlCommand.Compose(
                       typeof(Search <,>),
                       typeof(FABookPeriod.finPeriodID),
                       typeof(Where <, ,>),
                       typeof(FABookPeriod.bookID),
                       typeof(Equal <>),
                       typeof(Current <>),
                       BookType,
                       typeof(And <FABookPeriod.startDate, LessEqual <Required <FABookPeriod.startDate> >, And <FABookPeriod.endDate, Greater <Required <FABookPeriod.endDate> > > >))
                   )
        {
            if (BookType != null)
            {
                Type search = BqlCommand.Compose(
                    typeof(Search <, ,>),
                    typeof(FABookPeriod.finPeriodID),
                    typeof(Where <,>),
                    typeof(FABookPeriod.bookID),
                    typeof(Equal <>),
                    typeof(Optional <>),
                    BookType,
                    typeof(OrderBy <Asc <FABookPeriod.finPeriodID> >));

                _Attributes.Add(new PXSelectorAttribute(search));
                _SelAttrIndex = _Attributes.Count - 1;
            }
        }
Ejemplo n.º 14
0
 protected virtual Type GetSearchTypeRestrictedByDate(Type selectorSearchType, Type dateType)
 {
     selectorSearchType = selectorSearchType ?? GetDefaultSelectorSearchType();
     if (dateType != null)
     {
         BqlCommand select    = BqlCommand.CreateInstance(selectorSearchType) ?? throw new ArgumentNullException("BqlCommand.CreateInstance(selectorSearchType)");
         Type       whereDate = BqlCommand.Compose(
             typeof(Where <, ,>),
             typeof(FABookPeriod.startDate),
             typeof(LessEqual <>),
             typeof(Current <>),
             dateType,
             typeof(And <,>),
             typeof(FABookPeriod.endDate),
             typeof(Greater <>),
             typeof(Current <>),
             dateType);
         select = select.WhereAnd(whereDate);
         Type[] decomposed = BqlCommand.Decompose(select.GetSelectType());
         decomposed[0]      = BqlHelper.SelectToSearch[decomposed[0]];
         decomposed[1]      = typeof(FABookPeriod.finPeriodID);
         selectorSearchType = BqlCommand.Compose(decomposed);
     }
     return(selectorSearchType);
 }
        public RetainagePercentAttribute(
            Type retainageApplyField,
            Type defRetainagePctField,
            Type retainedAmtFormula,
            Type curyRetainageAmtField,
            Type retainagePctField)
            : base()
        {
            Initialize();

            Type retainageApplyType = typeof(Constant).IsAssignableFrom(retainageApplyField)
                                ? retainageApplyField
                                : BqlCommand.Compose(typeof(Current <>), retainageApplyField);

            Type defRetainagePctType = typeof(Constant).IsAssignableFrom(defRetainagePctField)
                                ? defRetainagePctField
                                : BqlCommand.Compose(typeof(Current <>), defRetainagePctField);

            defaultType = BqlCommand.Compose(
                typeof(Switch <,>), typeof(Case <,>), typeof(Where <,>), retainageApplyType, typeof(Equal <True>),
                defRetainagePctType,
                typeof(decimal0));

            formulaType = BqlCommand.Compose(
                typeof(Switch <,>), typeof(Case <,>), typeof(Where <,>), retainageApplyType, typeof(Equal <True>),
                typeof(ExternalValue <>), typeof(Switch <,>), typeof(Case <,>), typeof(Where <,>), retainedAmtFormula, typeof(NotEqual <decimal0>),
                typeof(Mult <,>), typeof(Div <,>), curyRetainageAmtField, retainedAmtFormula, typeof(decimal100),
                typeof(decimal0),
                typeof(decimal0));

            verifyType = BqlCommand.Compose(
                typeof(Where <, ,>), retainagePctField, typeof(LessEqual <decimal100>),
                typeof(And <,>), retainagePctField, typeof(GreaterEqual <decimal0>));
        }
        public ContractAttribute(Type WhereType)
        {
            Type SearchType =
                BqlCommand.Compose(
                    typeof(Search2 <, , ,>),
                    typeof(Contract.contractID),
                    typeof(InnerJoin <ContractBillingSchedule, On <ContractBillingSchedule.contractID, Equal <Contract.contractID> > >),
                    typeof(Where <, ,>),
                    typeof(Contract.isTemplate),
                    typeof(Equal <boolFalse>),
                    typeof(And <, ,>),
                    typeof(Contract.baseType),
                    typeof(Equal <>),
                    typeof(Contract.ContractBaseType),
                    typeof(And <>),
                    WhereType,
                    typeof(OrderBy <Desc <Contract.contractCD> >));

            PXDimensionSelectorAttribute select = new PXDimensionSelectorAttribute(DimensionName, SearchType, typeof(Contract.contractCD),
                                                                                   typeof(Contract.contractCD), typeof(Contract.customerID), typeof(Contract.locationID), typeof(Contract.description), typeof(Contract.status), typeof(Contract.expireDate), typeof(ContractBillingSchedule.lastDate), typeof(ContractBillingSchedule.nextDate));

            select.DescriptionField = typeof(Contract.description);
            _Attributes.Add(select);
            _SelAttrIndex = _Attributes.Count - 1;
        }
Ejemplo n.º 17
0
 protected override Type GetSearchType(Type projectId)
 {
     return(BqlCommand.Compose(typeof(Search <,>), typeof(PMTask.taskID),
                               typeof(Where <, ,>), typeof(PMTask.projectID), typeof(Equal <>), typeof(Optional <>), projectId,
                               typeof(And <PMTask.type, NotEqual <ProjectTaskType.revenue>,
                                           And <PMTask.status, Equal <ProjectTaskStatus.active> > >)));
 }
Ejemplo n.º 18
0
        public ContractInventoryItemAttribute()
        {
            Type SearchType =
                BqlCommand.Compose(
                    typeof(Search5 <, ,>),
                    typeof(InventoryItem.inventoryID),
                    typeof(LeftJoin <ARSalesPrice, On <ARSalesPrice.inventoryID, Equal <InventoryItem.inventoryID>,
                                                       And <ARSalesPrice.uOM, Equal <InventoryItem.baseUnit>,
                                                            And <ARSalesPrice.curyID, Equal <Current <ContractItem.curyID> >,
                                                                 And <ARSalesPrice.priceType, Equal <PriceTypes.basePrice>,
                                                                      And <ARSalesPrice.breakQty, Equal <decimal0>,
                                                                           And <ARSalesPrice.isPromotionalPrice, Equal <False>,
                                                                                And <ARSalesPrice.isFairValue, Equal <False> > > > > > > > >),
                    typeof(Aggregate <GroupBy <InventoryItem.inventoryID,
                                               GroupBy <InventoryItem.stkItem> > >));

            PXDimensionSelectorAttribute select = new PXDimensionSelectorAttribute(
                DimensionName,
                SearchType,
                typeof(InventoryItem.inventoryCD)
                );

            select.DescriptionField = typeof(InventoryItem.descr);
            _Attributes.Add(select);
            _SelAttrIndex = _Attributes.Count - 1;
        }
        private void InitializeAttributeRestrictions(bool onlyActive, Type organizationFieldType, Type featureFieldType)
        {
            if (onlyActive)
            {
                _Attributes.Add(new PXRestrictorAttribute(typeof(Where <Branch.active, Equal <True> >), Messages.BranchInactive));
            }

            PXRestrictorAttribute organizationRestrictor;

            if (featureFieldType == null)
            {
                organizationRestrictor = new PXRestrictorAttribute(BqlCommand.Compose(
                                                                       typeof(Where <, ,>),
                                                                       typeof(Branch.organizationID), typeof(Equal <>), typeof(Optional2 <>), organizationFieldType,
                                                                       typeof(Or <,>), typeof(Optional2 <>), organizationFieldType, typeof(IsNull)),
                                                                   Messages.TheSpecifiedBranchDoesNotBelongToTheSelectedCompany);
            }
            else
            {
                organizationRestrictor = new PXRestrictorAttribute(BqlCommand.Compose(
                                                                       typeof(Where <, ,>),
                                                                       typeof(Branch.organizationID), typeof(Equal <>), typeof(Optional2 <>), organizationFieldType,
                                                                       typeof(And <, ,>), typeof(Optional2 <>), organizationFieldType, typeof(IsNotNull),
                                                                       typeof(Or <>), typeof(Where <, ,>), typeof(Optional2 <>), organizationFieldType, typeof(IsNull),
                                                                       typeof(And <>), typeof(Not <>), typeof(FeatureInstalled <>), featureFieldType),
                                                                   Messages.TheSpecifiedBranchDoesNotBelongToTheSelectedCompany);
            }
            _Attributes.Add(organizationRestrictor);
        }
Ejemplo n.º 20
0
        private static Type getAPDocumentSelect(bool groupBy = false)
        {
            Type selType = typeof(Select2 <, ,>);

            if (groupBy)
            {
                selType = typeof(Select5 <, , ,>);
            }

            Type table = typeof(APInvoice);

            Type join = typeof(InnerJoin <Vendor, On <Vendor.bAccountID, Equal <APInvoice.vendorID> >,
                                          InnerJoin <CurrencyInfo,
                                                     On <CurrencyInfo.curyInfoID, Equal <APInvoice.curyInfoID> >,
                                                     LeftJoin <APAdjust, On <APAdjust.adjdDocType, Equal <APInvoice.docType>,
                                                                             And <APAdjust.adjdRefNbr, Equal <APInvoice.refNbr>,
                                                                                  And <APAdjust.released, Equal <False> > > >,
                                                               LeftJoin <APPayment, On <APPayment.docType, Equal <APInvoice.docType>,
                                                                                        And <APPayment.refNbr, Equal <APInvoice.refNbr>,
                                                                                             And <Where <APPayment.docType, Equal <APDocType.prepayment>, Or <APPayment.docType, Equal <APDocType.debitAdj> > > > > > > > > >);

            Type where = typeof(Where <APInvoice.openDoc, Equal <True>,
                                       And2 <Where <APInvoice.released, Equal <True>, Or <APInvoice.prebooked, Equal <True> > >,
                                             And <APAdjust.adjgRefNbr, IsNull,
                                                  And <APPayment.refNbr, IsNull,
                                                       And2 <Match <Vendor, Current <AccessInfo.userName> >,
                                                             And2 <Where <APInvoice.curyID, Equal <Current <ApproveBillsFilter.curyID> >,
                                                                          Or <Current <ApproveBillsFilter.curyID>, IsNull> >,
                                                                   And2 <Where2 <Where <Current <ApproveBillsFilter.showApprovedForPayment>, Equal <True>,
                                                                                        And <APInvoice.paySel, Equal <True> > >,
                                                                                 Or <Where <Current <ApproveBillsFilter.showNotApprovedForPayment>, Equal <True>,
                                                                                            And <APInvoice.paySel, Equal <False> > > > >,
                                                                         And2 <Where <Vendor.bAccountID, Equal <Current <ApproveBillsFilter.vendorID> >,
                                                                                      Or <Current <ApproveBillsFilter.vendorID>, IsNull> >,
                                                                               And2 <Where <Vendor.vendorClassID, Equal <Current <ApproveBillsFilter.vendorClassID> >,
                                                                                            Or <Current <ApproveBillsFilter.vendorClassID>, IsNull> >,
                                                                                     And <Where2 <Where2 <Where <Current <ApproveBillsFilter.showPayInLessThan>, Equal <True>, And <APInvoice.payDate, LessEqual <Required <APInvoice.payDate> > > >,
                                                                                                          Or2 <Where <Current <ApproveBillsFilter.showDueInLessThan>, Equal <True>,
                                                                                                                      And <APInvoice.dueDate, LessEqual <Required <APInvoice.dueDate> > > >,
                                                                                                               Or <Where <Current <ApproveBillsFilter.showDiscountExpiresInLessThan>, Equal <True>,
                                                                                                                          And <APInvoice.discDate, LessEqual <Required <APInvoice.discDate> > > > > > >,
                                                                                                  Or <Where <Current <ApproveBillsFilter.showPayInLessThan>, Equal <False>,
                                                                                                             And <Current <ApproveBillsFilter.showDueInLessThan>, Equal <False>,
                                                                                                                  And <Current <ApproveBillsFilter.showDiscountExpiresInLessThan>, Equal <False> > > > > > > > > > > > > > > >);

            Type aggr = typeof(Aggregate <
                                   GroupBy <APInvoice.paySel,
                                            Sum <APInvoice.docBal,
                                                 Sum <APInvoice.curyDocBal> > > >);

            if (groupBy)
            {
                return(BqlCommand.Compose(selType, table, join, where, aggr));
            }
            else
            {
                return(BqlCommand.Compose(selType, table, join, where));
            }
        }
Ejemplo n.º 21
0
        protected virtual void MarkAs(PXCache cache, CRActivity row, Guid UserID, int status)
        {
            if (IsImport || row.NoteID == null)
            {
                return;
            }

            var noteidType = typeof(TMaster).GetNestedType(typeof(CRActivity.noteID).Name);
            var ownerType  = typeof(TMaster).GetNestedType(typeof(CRActivity.ownerID).Name);

            var select = BqlCommand.Compose(
                typeof(Select <,>), typeof(EPView), typeof(Where <, ,>),
                typeof(EPView.noteID), typeof(Equal <>), typeof(Required <>), noteidType,
                typeof(And <,>), typeof(EPView.userID), typeof(Equal <>), typeof(Required <>), ownerType
                );

            EPView epview = (EPView) new PXView(this, false,
                                                BqlCommand.CreateInstance(select)).SelectSingle(row.NoteID, UserID);

            if (epview == null)
            {
                epview = new EPView
                {
                    NoteID = row.NoteID,
                    UserID = UserID,
                };
            }
            else
            {
                epview = PXCache <EPView> .CreateCopy(epview);
            }

            if (status == EPViewStatusAttribute.VIEWED
                                        ? epview.Status != EPViewStatusAttribute.VIEWED
                                        : epview.Status == EPViewStatusAttribute.VIEWED)
            {
                epview.Status = status;
                EPViews.Update(epview);

                bool isDirty = false;
                foreach (PXCache c in Views.Caches.Where(t => t != typeof(EPView)).Select(t => Caches[t]))
                {
                    isDirty = c.Inserted.ToArray <object>().Any() || c.Updated.ToArray <object>().Any() || c.Deleted.ToArray <object>().Any();
                    if (isDirty)
                    {
                        break;
                    }
                }
                if (!isDirty)
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        Persist();
                        ts.Complete();
                    }
                }
                EPViews.Cache.IsDirty = false;
            }
        }
Ejemplo n.º 22
0
        public static BqlCommand CreateSelectCommand(Type entityType, Type fieldType)
        {
            Type required = BqlCommand.Compose(typeof(Required <>), fieldType);
            Type equal    = BqlCommand.Compose(typeof(Equal <>), required);

            Type where = BqlCommand.Compose(typeof(Where <,>), fieldType, equal);
            return(BqlCommand.CreateInstance(typeof(Select <,>), entityType, where));
        }
Ejemplo n.º 23
0
        private static int?GetAssignmentMapId(PXGraph graph)
        {
            BqlCommand search = (BqlCommand)Activator.CreateInstance(BqlCommand.Compose(typeof(Search <>), typeof(TAssignmentMapField)));
            PXView     view   = new PXView(graph, true, BqlCommand.CreateInstance(search.GetSelectType()));
            object     row    = view.SelectSingle();

            return(row.With(_ => (int?)view.Cache.GetValue(_, ((IBqlSearch)search).GetField().Name)));
        }
Ejemplo n.º 24
0
        protected virtual Type GetBQLStatement()
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(PrintInvoicesFilter),
                typeof(ARInvoice.workgroupID),
                typeof(ARInvoice.ownerID));

            Type printWhere =
                typeof(Where <ARInvoice.hold, Equal <False>, And <ARInvoice.scheduled, Equal <False>, And <ARInvoice.voided, Equal <False>,
                                                                                                           And <ARInvoice.dontPrint, Equal <False>,
                                                                                                                And <ARInvoice.printed, NotEqual <True> > > > > >);
            Type emailWhere =
                typeof(Where <ARInvoice.hold, Equal <False>, And <ARInvoice.scheduled, Equal <False>, And <ARInvoice.voided, Equal <False>,
                                                                                                           And <ARInvoice.dontEmail, Equal <False>,
                                                                                                                And <ARInvoice.emailed, NotEqual <True> > > > > >);

            Type dateWhere =
                typeof(Where <ARInvoice.docDate, LessEqual <Current <PrintInvoicesFilter.endDate> >,
                              And <ARInvoice.docDate, GreaterEqual <Current <PrintInvoicesFilter.beginDate> > > >);

            Type whereAnd;

            if (Filter.Current.ShowAll == true)
            {
                dateWhere = typeof(Where <True, Equal <True> >);
                whereAnd  = Filter.Current.Action == "<SELECT>" ? typeof(Where <True, Equal <False> >) : typeof(Where <ARInvoice.hold, Equal <False>, And <ARInvoice.scheduled, Equal <False>, And <ARInvoice.voided, Equal <False> > > >);
            }
            else
            {
                whereAnd = Filter.Current.Action == "<SELECT>" ? typeof(Where <True, Equal <False> >) : typeof(Where <True, Equal <True> >);

                string onlyNotPrinted = (string)ARDocumentList.GetTargetFill(null, null, null, Filter.Current.Action, "@OnlyNotPrinted");
                string onlyNotEmailed = (string)ARDocumentList.GetTargetFill(null, null, null, Filter.Current.Action, "@OnlyNotEmailed");

                if (onlyNotEmailed != null)
                {
                    whereAnd = emailWhere;
                }

                if (onlyNotPrinted != null)
                {
                    whereAnd = printWhere;
                }
            }


            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(ARInvoice),
                    typeof(InnerJoinSingleTable <Customer, On <Customer.bAccountID, Equal <ARInvoice.customerID> > >),
                    typeof(Where2 <,>),
                    typeof(Match <Customer, Current <AccessInfo.userName> >),
                    typeof(And2 <,>), whereAnd,
                    typeof(And2 <,>), dateWhere,
                    typeof(And <>), where);

            return(select);
        }
Ejemplo n.º 25
0
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);

            BqlCommand search = (BqlCommand)Activator.CreateInstance(BqlCommand.Compose(typeof(Search <>), MigrationModeSetupField));
            PXView     view   = new PXView(sender.Graph, true, BqlCommand.CreateInstance(search.GetSelectType()));
            object     setup  = view.SelectSingle();

            IsMigrationModeEnabled = (view.Cache.GetValue(setup, MigrationModeSetupField.Name) as bool?) == true;
        }
Ejemplo n.º 26
0
        protected virtual PXView CreateIntView(PXGraph graph)
        {
            Type type = BqlCommand.Compose((new List <Type>()
            {
                typeof(Select <,>),
                typeof(RowToSelect),
                CreateWhere(graph)
            }).ToArray());

            return(new PXView(graph, true, BqlCommand.CreateInstance(new Type[] { type })));
        }
Ejemplo n.º 27
0
        protected virtual void TMasterFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            TMaster row = (TMaster)e.Row;

            if (row == null || row.ClassID == null)
            {
                return;
            }

            RelatedEntity pars = this.Caches <RelatedEntity>().Current as RelatedEntity;

            if (pars == null || pars.Type == null || pars.RefNoteID == null)
            {
                return;
            }

            EntityHelper helper     = new EntityHelper(this);
            Type         entityType = PXBuildManager.GetType(pars.Type, false);
            var          related    = new EntityHelper(this).GetEntityRow(entityType, pars.RefNoteID);

            if (related == null)
            {
                return;
            }

            Type graphType = helper.GetPrimaryGraphType(entityType, related, true);

            if (graphType == null)
            {
                return;
            }

            TMaster copy = PXCache <TMaster> .CreateCopy(row);

            PXGraph graph = CreateInstance(graphType);

            Type   noteType = EntityHelper.GetNoteType(entityType);
            PXView view     = new PXView(this, false, BqlCommand.CreateInstance(BqlCommand.Compose(typeof(Select <,>), entityType, typeof(Where <,>), noteType, typeof(Equal <>), typeof(Required <>), noteType)));

            graph.Caches[entityType].Current = view.SelectSingle(pars.RefNoteID);

            PXCache <TMaster> cache = graph.Caches <TMaster>();

            cache.SetDefaultExt(copy, typeof(CRActivity.bAccountID).Name);
            cache.SetDefaultExt(copy, typeof(CRActivity.contactID).Name);
            if (copy.BAccountID != null)
            {
                row.BAccountID = copy.BAccountID;
            }
            if (copy.ContactID != null)
            {
                row.ContactID = copy.ContactID;
            }
        }
Ejemplo n.º 28
0
        public ComponentIDAttribute(Type WhereType, Type JoinType)
        {
            Type type = BqlCommand.Compose(new Type[] { typeof(Search2 <, ,>), typeof(SurveyComponent.componentID), JoinType, WhereType });
            var  selectorAttribute = new PXSelectorAttribute(type)
            {
                DescriptionField = typeof(SurveyComponent.description),
                CacheGlobal      = true
            };

            _Attributes.Add(selectorAttribute);
            _SelAttrIndex = _Attributes.Count - 1;
        }
        private static Type GetCommand()
        {
            var whereType = typeof(Where <EMailSyncAccountPreferences.policyName, IsNull>);

            return(BqlCommand.Compose(typeof(Search5 <, , ,>), typeof(EPEmployee.bAccountID),
                                      typeof(LeftJoin <Users, On <Users.pKID, Equal <EPEmployee.userID> >,
                                                       LeftJoin <EMailSyncAccountPreferences, On <EMailSyncAccountPreferences.employeeID, Equal <EPEmployee.bAccountID>,
                                                                                                  And <EMailSyncAccountPreferences.employeeID, NotEqual <Optional <EMailSyncAccountPreferences.employeeID> > > >,
                                                                 LeftJoin <EPEmployeePosition, On <EPEmployeePosition.employeeID, Equal <EPEmployee.bAccountID>, And <EPEmployeePosition.isActive, Equal <True> > > > > >),
                                      whereType,
                                      typeof(Aggregate <GroupBy <EPEmployee.acctCD> >)));
        }
        protected virtual string GetBasicNumberingID()
        {
            GLWorkBook currentWB = this.WorkBooks.Current;

            if (currentWB == null || currentWB.Module == null || currentWB.DocType == null)
            {
                return(null);
            }
            Type numberingField;

            switch (currentWB.Module)
            {
            case BatchModule.CA:
                numberingField = typeof(CASetup.registerNumberingID);
                break;

            case BatchModule.GL:
                numberingField = BatchModule.NumberingAttribute.GetNumberingIDField(BatchModule.GL);
                break;

            case BatchModule.AP:
                numberingField = AP.APInvoiceType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                if (numberingField == null)
                {
                    numberingField = AP.APPaymentType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                }
                break;

            case BatchModule.AR:
                numberingField = AR.ARInvoiceType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                if (numberingField == null)
                {
                    numberingField = AR.ARPaymentType.NumberingAttribute.GetNumberingIDField(currentWB.DocType);
                }
                break;

            default: return(null);
            }
            if (numberingField == null)
            {
                return(null);
            }
            Type select =
                BqlCommand.Compose(
                    typeof(Select <,>), typeof(CS.Numbering),
                    typeof(Where <,>), typeof(CS.Numbering.numberingID),
                    typeof(Equal <>), typeof(Current <>), numberingField);
            PXView view = new PXView(this, false, BqlCommand.CreateInstance(select));
            var    item = view.SelectSingle();

            return(((CS.Numbering)item).NumberingID);
        }