protected virtual void PMRateDefinition_Sequence_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            PMRateDefinition row = e.Row as PMRateDefinition;

            if (row != null)
            {
                e.NewValue = GetNextSequence();
            }
        }
        protected virtual void PMRateDefinition_RateTableID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            PMRateDefinition row = e.Row as PMRateDefinition;

            if (row != null)
            {
                e.NewValue = Filter.Current.RateTableID;
            }
        }
Example #3
0
        protected virtual string RunEntryValidationAndReturnErrors(PMRateDefinition definition, string rateCodeID)
        {
            Dictionary <string, RateCodeData> otherRateCodes = new Dictionary <string, RateCodeData>();

            #region Fill Hshtables with records from other rate codes
            if (definition.Project == true)
            {
                foreach (PMProjectRate item in PXSelect <PMProjectRate, Where <PMProjectRate.rateDefinitionID, Equal <Required <PMProjectRate.rateDefinitionID> >, And <PMProjectRate.rateCodeID, NotEqual <Required <PMProjectRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    if (!otherRateCodes.ContainsKey(item.RateCodeID))
                    {
                        otherRateCodes.Add(item.RateCodeID, new RateCodeData(item.RateCodeID));
                    }
                    otherRateCodes[item.RateCodeID].Projects.Add(item.ProjectCD.ToUpper().Trim(), item);
                }
            }

            if (definition.Task == true)
            {
                foreach (PMTaskRate item in PXSelect <PMTaskRate, Where <PMTaskRate.rateDefinitionID, Equal <Required <PMTaskRate.rateDefinitionID> >, And <PMTaskRate.rateCodeID, NotEqual <Required <PMTaskRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    if (!otherRateCodes.ContainsKey(item.RateCodeID))
                    {
                        otherRateCodes.Add(item.RateCodeID, new RateCodeData(item.RateCodeID));
                    }
                    otherRateCodes[item.RateCodeID].Tasks.Add(item.TaskCD.ToUpper().Trim(), item);
                }
            }

            if (definition.AccountGroup == true)
            {
                foreach (PMAccountGroupRate item in PXSelect <PMAccountGroupRate, Where <PMAccountGroupRate.rateDefinitionID, Equal <Required <PMAccountGroupRate.rateDefinitionID> >, And <PMAccountGroupRate.rateCodeID, NotEqual <Required <PMAccountGroupRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    if (!otherRateCodes.ContainsKey(item.RateCodeID))
                    {
                        otherRateCodes.Add(item.RateCodeID, new RateCodeData(item.RateCodeID));
                    }
                    otherRateCodes[item.RateCodeID].AccountGroups.Add(item.AccountGroupID.Value, item);
                }
            }

            if (definition.RateItem == true)
            {
                foreach (PMItemRate item in PXSelect <PMItemRate, Where <PMItemRate.rateDefinitionID, Equal <Required <PMItemRate.rateDefinitionID> >, And <PMItemRate.rateCodeID, NotEqual <Required <PMItemRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    if (!otherRateCodes.ContainsKey(item.RateCodeID))
                    {
                        otherRateCodes.Add(item.RateCodeID, new RateCodeData(item.RateCodeID));
                    }
                    otherRateCodes[item.RateCodeID].Inventory.Add(item.InventoryID.Value, item);
                }
            }

            if (definition.Employee == true)
            {
                foreach (PMEmployeeRate item in PXSelect <PMEmployeeRate, Where <PMEmployeeRate.rateDefinitionID, Equal <Required <PMEmployeeRate.rateDefinitionID> >, And <PMEmployeeRate.rateCodeID, NotEqual <Required <PMEmployeeRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    if (!otherRateCodes.ContainsKey(item.RateCodeID))
                    {
                        otherRateCodes.Add(item.RateCodeID, new RateCodeData(item.RateCodeID));
                    }
                    otherRateCodes[item.RateCodeID].Employees.Add(item.EmployeeID.Value, item);
                }
            }
            #endregion

            string errors = null;

            List <Entity <string, PMProjectRate, PMProject> >         data1 = new List <Entity <string, PMProjectRate, PMProject> >();         //project
            List <Entity <string, PMTaskRate, PMTask> >               data2 = new List <Entity <string, PMTaskRate, PMTask> >();               //task
            List <Entity <int?, PMAccountGroupRate, PMAccountGroup> > data3 = new List <Entity <int?, PMAccountGroupRate, PMAccountGroup> >(); //accountgroup
            List <Entity <int?, PMItemRate, InventoryItem> >          data4 = new List <Entity <int?, PMItemRate, InventoryItem> >();          //inventory
            List <Entity <int?, PMEmployeeRate, BAccount> >           data5 = new List <Entity <int?, PMEmployeeRate, BAccount> >();           //employee

            #region Fill Combinations
            if (definition.Project == true)
            {
                foreach (PXResult <PMProjectRate, PMProject> project in Projects.Select())
                {
                    if (Projects.Cache.GetStatus((PMProjectRate)project) != PXEntryStatus.Deleted)
                    {
                        data1.Add(new Entity <string, PMProjectRate, PMProject>(((PMProjectRate)project).ProjectCD, (PMProjectRate)project, (PMProject)project));
                    }
                }
            }

            if (definition.Task == true)
            {
                foreach (PMTaskRate task in Tasks.Select())
                {
                    if (Tasks.Cache.GetStatus(task) != PXEntryStatus.Deleted)
                    {
                        data2.Add(new Entity <string, PMTaskRate, PMTask>(task.TaskCD, task, null));
                    }
                }
            }

            if (definition.AccountGroup == true)
            {
                foreach (PXResult <PMAccountGroupRate, PMAccountGroup> accountGroup in AccountGroups.Select())
                {
                    if (AccountGroups.Cache.GetStatus((PMAccountGroupRate)accountGroup) != PXEntryStatus.Deleted)
                    {
                        data3.Add(new Entity <int?, PMAccountGroupRate, PMAccountGroup>(((PMAccountGroupRate)accountGroup).AccountGroupID, (PMAccountGroupRate)accountGroup, (PMAccountGroup)accountGroup));
                    }
                }
            }

            if (definition.RateItem == true)
            {
                foreach (PXResult <PMItemRate, InventoryItem> item in Items.Select())
                {
                    if (Items.Cache.GetStatus((PMItemRate)item) != PXEntryStatus.Deleted)
                    {
                        data4.Add(new Entity <int?, PMItemRate, InventoryItem>(((PMItemRate)item).InventoryID, (PMItemRate)item, (InventoryItem)item));
                    }
                }
            }

            if (definition.Employee == true)
            {
                foreach (PXResult <PMEmployeeRate, BAccount> employee in Employees.Select())
                {
                    if (Employees.Cache.GetStatus((PMEmployeeRate)employee) != PXEntryStatus.Deleted)
                    {
                        data5.Add(new Entity <int?, PMEmployeeRate, BAccount>(((PMEmployeeRate)employee).EmployeeID, (PMEmployeeRate)employee, (BAccount)employee));
                    }
                }
            }

            if (data1.Count == 0)
            {
                data1.Add(new Entity <string, PMProjectRate, PMProject>());
            }
            if (data2.Count == 0)
            {
                data2.Add(new Entity <string, PMTaskRate, PMTask>());
            }
            if (data3.Count == 0)
            {
                data3.Add(new Entity <int?, PMAccountGroupRate, PMAccountGroup>());
            }
            if (data4.Count == 0)
            {
                data4.Add(new Entity <int?, PMItemRate, InventoryItem>());
            }
            if (data5.Count == 0)
            {
                data5.Add(new Entity <int?, PMEmployeeRate, BAccount>());
            }

            #endregion

            StringBuilder sb = new StringBuilder();

            foreach (RateCodeData otherRateCode in otherRateCodes.Values)
            {
                string error = otherRateCode.Validate(data1, data2, data3, data4, data5);
                if (error != null)
                {
                    sb.AppendLine(error);
                }
            }
            if (sb.Length > 0)
            {
                errors = sb.ToString();
            }
            return(errors);
        }
Example #4
0
		protected virtual decimal? GetRate(PMRateDefinition rd)
		{
			bool isApplicable = true;

			if (rd.Project == true)
			{
				if (!IsProjectFit(rd.RateDefinitionID, tran.ProjectID))
				{
					isApplicable = false;
				}
			}

			if (rd.Task == true)
			{
				if (!IsTaskFit(rd.RateDefinitionID, tran.ProjectID, tran.TaskID))
				{
					isApplicable = false;
				}
			}

			if (rd.AccountGroup == true)
			{
				if (!IsAccountGroupFit(rd.RateDefinitionID, tran.AccountGroupID))
				{
					isApplicable = false;
				}
			}

			if (rd.RateItem == true)
			{
				if (!IsItemFit(rd.RateDefinitionID, tran.InventoryID))
				{
					isApplicable = false;
				}
			}

			if (rd.Employee == true)
			{
				if (!IsEmployeeFit(rd.RateDefinitionID, tran.ResourceID))
				{
					isApplicable = false;
				}
			}

			if (isApplicable)
			{
				PXSelectBase<PMRate> select = new PXSelect<PMRate,
					Where<PMRate.rateDefinitionID, Equal<Required<PMRate.rateDefinitionID>>,
					And<Where<PMRate.startDate, LessEqual<Required<PMRate.startDate>>,
					And2<Where<PMRate.endDate, GreaterEqual<Required<PMRate.endDate>>>, Or<PMRate.endDate, IsNull>>>>>>(graph);

				PMRate rate = select.Select(rd.RateDefinitionID, tran.Date, tran.Date);
				trace.AppendFormat("	Searching Rate for Date:{0}", tran.Date);
                
				if (rate != null)
				{
					return rate.Rate;
				}
				else

					return null;
			}
			else
			{
				return null;
			}

		}
Example #5
0
        protected virtual decimal?GetRate(PMRateDefinition rd, PMTran tran)
        {
            bool isApplicable = true;

            List <string> finalList = null;

            if (rd.Project == true)
            {
                List <string> rateCodes;
                if (!IsProjectFit(rd.RateDefinitionID, tran.ProjectID, out rateCodes))
                {
                    isApplicable = false;
                }
                else
                {
                    finalList = rateCodes;
                }
            }

            if (rd.Task == true)
            {
                List <string> rateCodes;
                if (!IsTaskFit(rd.RateDefinitionID, tran.ProjectID, tran.TaskID, out rateCodes))
                {
                    isApplicable = false;
                }
                else
                {
                    if (finalList == null)
                    {
                        finalList = rateCodes;
                    }
                    else
                    {
                        finalList = new List <string>(finalList.Intersect(rateCodes));
                        if (finalList.Count == 0)
                        {
                            isApplicable = false;
                        }
                    }
                }
            }

            if (rd.AccountGroup == true)
            {
                List <string> rateCodes;
                if (!IsAccountGroupFit(rd.RateDefinitionID, tran.AccountGroupID, out rateCodes))
                {
                    isApplicable = false;
                }
                else
                {
                    if (finalList == null)
                    {
                        finalList = rateCodes;
                    }
                    else
                    {
                        finalList = new List <string>(finalList.Intersect(rateCodes));
                        if (finalList.Count == 0)
                        {
                            isApplicable = false;
                        }
                    }
                }
            }

            if (rd.RateItem == true)
            {
                List <string> rateCodes;
                if (!IsItemFit(rd.RateDefinitionID, tran.InventoryID, out rateCodes))
                {
                    isApplicable = false;
                }
                else
                {
                    if (finalList == null)
                    {
                        finalList = rateCodes;
                    }
                    else
                    {
                        finalList = new List <string>(finalList.Intersect(rateCodes));
                        if (finalList.Count == 0)
                        {
                            isApplicable = false;
                        }
                    }
                }
            }

            if (rd.Employee == true)
            {
                List <string> rateCodes;
                if (!IsEmployeeFit(rd.RateDefinitionID, tran.ResourceID, out rateCodes))
                {
                    isApplicable = false;
                }
                else
                {
                    if (finalList == null)
                    {
                        finalList = rateCodes;
                    }
                    else
                    {
                        finalList = new List <string>(finalList.Intersect(rateCodes));
                        if (finalList.Count == 0)
                        {
                            isApplicable = false;
                        }
                    }
                }
            }

            if (isApplicable)
            {
                string ratecodeid = null;
                if (finalList != null && finalList.Count > 0)
                {
                    ratecodeid = finalList[0];
                    Debug.Assert(finalList.Count == 1, "Intersaction of all ratecodes must result to single element.");
                }


                PMRate rate;
                if (!string.IsNullOrEmpty(ratecodeid))
                {
                    PXSelectBase <PMRate> select = new PXSelect <PMRate,
                                                                 Where <PMRate.rateDefinitionID, Equal <Required <PMRate.rateDefinitionID> >,
                                                                        And <Where <PMRate.rateCodeID, Equal <Required <PMRate.rateCodeID> >,
                                                                                    And <Where <PMRate.startDate, LessEqual <Required <PMRate.startDate> >,
                                                                                                And2 <Where <PMRate.endDate, GreaterEqual <Required <PMRate.endDate> > >, Or <PMRate.endDate, IsNull> > > > > > > >(graph);

                    rate = select.Select(rd.RateDefinitionID, ratecodeid, tran.Date, tran.Date);
                }
                else
                {
                    PXSelectBase <PMRate> select = new PXSelect <PMRate,
                                                                 Where <PMRate.rateDefinitionID, Equal <Required <PMRate.rateDefinitionID> >,
                                                                        And <Where <PMRate.startDate, LessEqual <Required <PMRate.startDate> >,
                                                                                    And2 <Where <PMRate.endDate, GreaterEqual <Required <PMRate.endDate> > >, Or <PMRate.endDate, IsNull> > > > > >(graph);
                    rate = select.Select(rd.RateDefinitionID, tran.Date, tran.Date);
                }
                trace.AppendFormat("	Searching Rate for Date:{0}", tran.Date);

                if (rate != null)
                {
                    return(rate.Rate);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Example #6
0
        protected virtual string RunEntryValidationAndReturnErrors(PMRateDefinition definition, string rateCodeID)
        {
            Hashtable projects      = new Hashtable();
            Hashtable tasks         = new Hashtable();
            Hashtable accountGroups = new Hashtable();
            Hashtable inventory     = new Hashtable();
            Hashtable employees     = new Hashtable();

            #region Fill Hshtables with records from other rate codes
            if (definition.Project == true)
            {
                foreach (PMProjectRate item in PXSelect <PMProjectRate, Where <PMProjectRate.rateDefinitionID, Equal <Required <PMProjectRate.rateDefinitionID> >, And <PMProjectRate.rateCodeID, NotEqual <Required <PMProjectRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    projects.Add(item.ProjectCD.ToUpper().Trim(), item);
                }
            }

            if (definition.Task == true)
            {
                foreach (PMTaskRate item in PXSelect <PMTaskRate, Where <PMTaskRate.rateDefinitionID, Equal <Required <PMTaskRate.rateDefinitionID> >, And <PMTaskRate.rateCodeID, NotEqual <Required <PMTaskRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    tasks.Add(item.TaskCD.ToUpper().Trim(), item);
                }
            }

            if (definition.AccountGroup == true)
            {
                foreach (PMAccountGroupRate item in PXSelect <PMAccountGroupRate, Where <PMAccountGroupRate.rateDefinitionID, Equal <Required <PMAccountGroupRate.rateDefinitionID> >, And <PMAccountGroupRate.rateCodeID, NotEqual <Required <PMAccountGroupRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    accountGroups.Add(item.AccountGroupID.Value, item);
                }
            }

            if (definition.RateItem == true)
            {
                foreach (PMItemRate item in PXSelect <PMItemRate, Where <PMItemRate.rateDefinitionID, Equal <Required <PMItemRate.rateDefinitionID> >, And <PMItemRate.rateCodeID, NotEqual <Required <PMItemRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    inventory.Add(item.InventoryID.Value, item);
                }
            }

            if (definition.Employee == true)
            {
                foreach (PMEmployeeRate item in PXSelect <PMEmployeeRate, Where <PMEmployeeRate.rateDefinitionID, Equal <Required <PMEmployeeRate.rateDefinitionID> >, And <PMEmployeeRate.rateCodeID, NotEqual <Required <PMEmployeeRate.rateCodeID> > > > > .Select(this, definition.RateDefinitionID, rateCodeID))
                {
                    employees.Add(item.EmployeeID.Value, item);
                }
            }
            #endregion

            string errors = null;

            List <Entity <string, PMProjectRate, PMProject> >         data1 = new List <Entity <string, PMProjectRate, PMProject> >();         //project
            List <Entity <string, PMTaskRate, PMTask> >               data2 = new List <Entity <string, PMTaskRate, PMTask> >();               //task
            List <Entity <int?, PMAccountGroupRate, PMAccountGroup> > data3 = new List <Entity <int?, PMAccountGroupRate, PMAccountGroup> >(); //accountgroup
            List <Entity <int?, PMItemRate, InventoryItem> >          data4 = new List <Entity <int?, PMItemRate, InventoryItem> >();          //inventory
            List <Entity <int?, PMEmployeeRate, BAccount> >           data5 = new List <Entity <int?, PMEmployeeRate, BAccount> >();           //employee

            #region Fill Combinations
            if (definition.Project == true)
            {
                foreach (PXResult <PMProjectRate, PMProject> project in Projects.Select())
                {
                    if (Projects.Cache.GetStatus((PMProjectRate)project) != PXEntryStatus.Deleted)
                    {
                        data1.Add(new Entity <string, PMProjectRate, PMProject>(((PMProjectRate)project).ProjectCD, (PMProjectRate)project, (PMProject)project));
                    }
                }
            }

            if (definition.Task == true)
            {
                foreach (PMTaskRate task in Tasks.Select())
                {
                    if (Tasks.Cache.GetStatus(task) != PXEntryStatus.Deleted)
                    {
                        data2.Add(new Entity <string, PMTaskRate, PMTask>(task.TaskCD, task, null));
                    }
                }
            }

            if (definition.AccountGroup == true)
            {
                foreach (PXResult <PMAccountGroupRate, PMAccountGroup> accountGroup in AccountGroups.Select())
                {
                    if (AccountGroups.Cache.GetStatus((PMAccountGroupRate)accountGroup) != PXEntryStatus.Deleted)
                    {
                        data3.Add(new Entity <int?, PMAccountGroupRate, PMAccountGroup>(((PMAccountGroupRate)accountGroup).AccountGroupID, (PMAccountGroupRate)accountGroup, (PMAccountGroup)accountGroup));
                    }
                }
            }

            if (definition.RateItem == true)
            {
                foreach (PXResult <PMItemRate, InventoryItem> item in Items.Select())
                {
                    if (Items.Cache.GetStatus((PMItemRate)item) != PXEntryStatus.Deleted)
                    {
                        data4.Add(new Entity <int?, PMItemRate, InventoryItem>(((PMItemRate)item).InventoryID, (PMItemRate)item, (InventoryItem)item));
                    }
                }
            }

            if (definition.Employee == true)
            {
                foreach (PXResult <PMEmployeeRate, BAccount> employee in Employees.Select())
                {
                    if (Employees.Cache.GetStatus((PMEmployeeRate)employee) != PXEntryStatus.Deleted)
                    {
                        data5.Add(new Entity <int?, PMEmployeeRate, BAccount>(((PMEmployeeRate)employee).EmployeeID, (PMEmployeeRate)employee, (BAccount)employee));
                    }
                }
            }

            if (data1.Count == 0)
            {
                data1.Add(new Entity <string, PMProjectRate, PMProject>());
            }
            if (data2.Count == 0)
            {
                data2.Add(new Entity <string, PMTaskRate, PMTask>());
            }
            if (data3.Count == 0)
            {
                data3.Add(new Entity <int?, PMAccountGroupRate, PMAccountGroup>());
            }
            if (data4.Count == 0)
            {
                data4.Add(new Entity <int?, PMItemRate, InventoryItem>());
            }
            if (data5.Count == 0)
            {
                data5.Add(new Entity <int?, PMEmployeeRate, BAccount>());
            }

            #endregion

            StringBuilder sb = new StringBuilder();

            foreach (Entity <string, PMProjectRate, PMProject> i1 in data1)
            {
                foreach (Entity <string, PMTaskRate, PMTask> i2 in data2)
                {
                    foreach (Entity <int?, PMAccountGroupRate, PMAccountGroup> i3 in data3)
                    {
                        foreach (Entity <int?, PMItemRate, InventoryItem> i4 in data4)
                        {
                            foreach (Entity <int?, PMEmployeeRate, BAccount> i5 in data5)
                            {
                                bool isDuplicate = true;

                                if (i1.Key != null && !projects.ContainsKey(i1.Key.ToUpper().Trim()))
                                {
                                    isDuplicate = false;
                                    continue;
                                }

                                if (i2.Key != null && !tasks.ContainsKey(i2.Key.ToUpper().Trim()))
                                {
                                    isDuplicate = false;
                                    continue;
                                }

                                if (i3.Key != null && !accountGroups.ContainsKey(i3.Key))
                                {
                                    isDuplicate = false;
                                    continue;
                                }

                                if (i4.Key != null && !inventory.ContainsKey(i4.Key))
                                {
                                    isDuplicate = false;
                                    continue;
                                }

                                if (i5.Key != null && !employees.ContainsKey(i5.Key))
                                {
                                    isDuplicate = false;
                                    continue;
                                }

                                if (isDuplicate)
                                {
                                    bool hasError = false;
                                    if (i1.Key != null)
                                    {
                                        sb.AppendFormat("Project:{0}, ", i1.Key);
                                        hasError = true;
                                    }

                                    if (i2.Key != null)
                                    {
                                        sb.AppendFormat("Task:{0}, ", i2.Key);
                                        hasError = true;
                                    }

                                    if (i3.Key != null)
                                    {
                                        sb.AppendFormat("Account Group:{0}, ", i3.Object.GroupCD);
                                        hasError = true;
                                    }

                                    if (i4.Key != null)
                                    {
                                        sb.AppendFormat("Inventory:{0}, ", i4.Object.InventoryCD);
                                        hasError = true;
                                    }

                                    if (i5.Key != null)
                                    {
                                        sb.AppendFormat("Employee:{0}", i5.Object.AcctCD);
                                        hasError = true;
                                    }

                                    if (hasError)
                                    {
                                        sb.AppendLine("");
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (sb.Length > 0)
            {
                errors = sb.ToString();
            }

            return(errors);
        }
Example #7
0
        protected virtual decimal?GetRate(PMRateDefinition rd)
        {
            bool isApplicable = true;

            if (rd.Project == true)
            {
                if (!IsProjectFit(rd.RateDefinitionID, tran.ProjectID))
                {
                    isApplicable = false;
                }
            }

            if (rd.Task == true)
            {
                if (!IsTaskFit(rd.RateDefinitionID, tran.ProjectID, tran.TaskID))
                {
                    isApplicable = false;
                }
            }

            if (rd.AccountGroup == true)
            {
                if (!IsAccountGroupFit(rd.RateDefinitionID, tran.AccountGroupID))
                {
                    isApplicable = false;
                }
            }

            if (rd.RateItem == true)
            {
                if (!IsItemFit(rd.RateDefinitionID, tran.InventoryID))
                {
                    isApplicable = false;
                }
            }

            if (rd.Employee == true)
            {
                if (!IsEmployeeFit(rd.RateDefinitionID, tran.ResourceID))
                {
                    isApplicable = false;
                }
            }

            if (isApplicable)
            {
                PXSelectBase <PMRate> select = new PXSelect <PMRate,
                                                             Where <PMRate.rateDefinitionID, Equal <Required <PMRate.rateDefinitionID> >,
                                                                    And <Where <PMRate.startDate, LessEqual <Required <PMRate.startDate> >,
                                                                                And2 <Where <PMRate.endDate, GreaterEqual <Required <PMRate.endDate> > >, Or <PMRate.endDate, IsNull> > > > > >(graph);

                PMRate rate = select.Select(rd.RateDefinitionID, tran.Date, tran.Date);
                trace.AppendFormat("	Searching Rate for Date:{0}", tran.Date);

                if (rate != null)
                {
                    return(rate.Rate);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }