public object Calculate(PXCache cache, object row, IBqlCreator formula, object[] records, int digit) { if (cache.Cached.Count() < 1 || !(row is CRActivity)) { return(null); } if ((bool?)CalcFormula(formula, cache, row) == true) { return(cache.GetValue <ReturnField>(row)); } if (records.Length < 1 || !(records[0] is CRActivity)) { return(null); } PXCache crActivityCache = cache.Graph.Caches[typeof(CRActivity)]; if (crActivityCache == null) { return(null); } return (crActivityCache.GetValue <ReturnField>( records.Where(a => ((bool?)CalcFormula(formula, crActivityCache, a) == true)) .OrderBy(a => ((CRActivity)a).CreatedDateTime) .LastOrDefault())); }
private void ParseOperand(PXGraph graph, List <IBqlParameter> pars, List <Type> tables, List <Type> fields, List <IBqlSortColumn> sortColumns, StringBuilder text, PX.Data.BqlCommand.Selection selection) { BqlCommand.EqualityList list = fields as BqlCommand.EqualityList; if (list != null) { list.NonStrict = true; } if (!typeof(IBqlCreator).IsAssignableFrom(typeof(UserID))) { if (graph != null && text != null) { text.Append(" ").Append(BqlCommand.GetSingleField(typeof(UserID), graph, tables, selection, BqlCommand.FieldPlace.Condition)); } if (fields != null) { fields.Add(typeof(UserID)); } } else { if (_operand == null) { _operand = _operand.createOperand <UserID>(); } _operand.Parse(graph, pars, tables, fields, sortColumns, text, selection); } }
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; }
public virtual bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection) { bool status = true; if (info.Fields is BqlCommand.EqualityList list) { list.NonStrict = true; } SQLExpression opUser = null; if (!typeof(IBqlCreator).IsAssignableFrom(typeof(OperandUser))) { if (info.BuildExpression) { opUser = BqlCommand.GetSingleExpression(typeof(OperandUser), graph, info.Tables, selection, BqlCommand.FieldPlace.Condition); } info.Fields?.Add(typeof(OperandUser)); } else { if (_operandUser == null) { _operandUser = _operandUser.createOperand <OperandUser>(); } status &= _operandUser.AppendExpression(ref opUser, graph, info, selection); } Query qin = new Query(); qin[typeof(EPCompanyTreeH.workGroupID)].From(typeof(EPCompanyTreeH)) .Join(typeof(EPCompanyTreeMember)) .On(SQLExpression.EQ(typeof(EPCompanyTreeH.parentWGID), typeof(EPCompanyTreeMember.workGroupID)) //.And(Column.SQLColumn(typeof(EPCompanyTreeH.parentWGID)).NotEqual(Column.SQLColumn(typeof(EPCompanyTreeH.workGroupID))) .And(Column.SQLColumn(typeof(EPCompanyTreeMember.active)).EQ(1)) .And(Column.SQLColumn(typeof(EPCompanyTreeMember.userID)).EQ(opUser))) //) .Where(new SQLConst(1).EQ(1)); Query qout = new Query(); //Append Tail removes main object, so we fieldNote will not be mapped. Skipping conditions for AppendTail if (info.Tables == null || info.Tables.Count <= 0 || info.Tables.Contains(BqlCommand.GetItemType <FieldNote>())) { qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup)) .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin) .And(SQLExpression.EQ(typeof(EntityWorkgroup.refNoteID), typeof(FieldNote)))); } else { qout[typeof(EntityWorkgroup.refNoteID)].From(typeof(EntityWorkgroup)) .Where(Column.SQLColumn(typeof(EntityWorkgroup.workGroupID)).In(qin)); } qout.Limit(-1); // prevent limiting of IN subqueries exp = exp.In(qout); return(status); }
private static object CalcFormula(IBqlCreator formula, PXCache cache, object item) { object value = null; bool? result = null; BqlFormula.Verify(cache, item, formula, ref result, ref value); return(value); }
protected static bool GetConditionResult(PXCache sender, object row, Type conditionType) { IBqlCreator condition = PXFormulaAttribute.InitFormula(conditionType); bool? result = null; object value = null; BqlFormula.Verify(sender, row, condition, ref result, ref value); return((value as bool?) == true); }
public PXBaseConditionAttribute(Type conditionType) : this() { Type condition = conditionType; if (typeof(IBqlWhere).IsAssignableFrom(condition)) { condition = BqlCommand.MakeGenericType(typeof(Switch <,>), typeof(Case <,>), conditionType, typeof(True), typeof(False)); } _Condition = PXFormulaAttribute.InitFormula(condition); }
public object Calculate(PXCache cache, object row, IBqlCreator formula, object[] records, int digit) { if (records.Length < 1 || !(records[0] is CRActivity)) { return(null); } return (cache.GetValue <ReturnField>( records.Where(a => ((bool?)CalcFormula(formula, cache, a) == true)) .OrderBy(a => ((CRActivity)a).CreatedDateTime) .LastOrDefault())); }
public object Calculate(PXCache cache, object row, IBqlCreator formula, object[] records, int digit) { if (cache.Cached.Count() < 1) { return(null); } bool isInitialCalc = typeof(TargetField) == typeof(CRActivityStatistics.initialOutgoingActivityCompletedAtDate) || typeof(TargetField) == typeof(CRActivityStatistics.initialOutgoingActivityCompletedAtNoteID); if (row is CRActivity && (bool?)CalcFormula(formula, cache, row) == true && isInitialCalc == false) { return(cache.GetValue <ReturnField>(row)); } if (records.Length < 1 || !(records[0] is CRActivity)) { return(null); } PXCache crActivityCache = cache.Graph.Caches[typeof(CRActivity)]; if (crActivityCache == null) { return(null); } if (isInitialCalc == true) { var value = crActivityCache.GetValue <ReturnField>( records.Where(a => ((bool?)CalcFormula(formula, crActivityCache, a) == true)) .OrderBy(a => ((CRActivity)a).CompletedDate) .FirstOrDefault()); return(value); } return (crActivityCache.GetValue <ReturnField>( records.Where(a => ((bool?)CalcFormula(formula, crActivityCache, a) == true)) .OrderBy(a => ((CRActivity)a).CreatedDateTime) .LastOrDefault())); }
public static bool CalculateDiscountedTaxes(PXCache cache, ARTaxTran artax, decimal cashDiscPercent) { bool? result = null; object value = null; IBqlCreator whereTaxable = (IBqlCreator)Activator.CreateInstance(typeof(WhereTaxable <Required <ARTaxTran.taxID> >)); whereTaxable.Verify(cache, artax, new List <object> { artax.TaxID }, ref result, ref value); artax.CuryDiscountedTaxableAmt = cashDiscPercent == 0m ? artax.CuryTaxableAmt : PXDBCurrencyAttribute.RoundCury(cache, artax, (decimal)(artax.CuryTaxableAmt * (1 - Decimal.Round(cashDiscPercent, 4)))); artax.CuryDiscountedPrice = cashDiscPercent == 0m ? artax.CuryTaxAmt : PXDBCurrencyAttribute.RoundCury(cache, artax, (decimal)(artax.TaxRate / 100m * artax.CuryDiscountedTaxableAmt)); return(result == true); }
public object Calculate(PXCache cache, object row, object oldrow, IBqlCreator formula, int digit) { return(null); }
public PXBaseConditionAttribute(Type conditionType) : this() { _Condition = PXFormulaAttribute.InitFormula(conditionType); }
public FormulaDefaultAttribute(Type formulaType) { Formula = PXFormulaAttribute.InitFormula(formulaType); }