How to create Expense Lines from Labor rates

Sironi
Kilo Sage

Hi,

Some one help me how to take Expense Line amount from Labor Rates.

i am using OOB script, as per Labor rate card  my Hourly_rate is 58.2$, but here is taking 100$ as default. How to Fix this.

1.we are maintaining all Users of Rate Lines under Default RateModel Only

2.we are NOT selecting any Rate Model on project level , it is always be empty in all projects, so system has to take always Default RateModel.

for that we updated RMRate (Script Include), as per this, if RateModel field is empty in Project , it will consider Default RateModel

 

19 REPLIES 19

Hi Mamta,

 

if i select Default RateModel in RateCard field at Project ,then it is working Good.

find_real_file.png

So How do i apply Default ratecard for ActualCost calculation.

as per client Requirement they are not ready to select RateModel in Project , that's only we added Default rate model sys_id in RMRates script-include , you can see script image above..... as per script if RateModel field empty in project then it will consider Default ratemodel .

 

Now please help me where do i add Default ratemodel sys_id for Actual Hours calculation as i did for RMRates

can i expect any updates .

Mamta9
Tera Expert

Hi Sironi,

 

I am out till tomorrow. I should be able to look more on this tomorrow.

Meanwhile, can you send me more info on the how your RMRates include script is being called?

Is it being referred in a business rule? please also paste the RMRate script code.

 

Regards

Mamta

RMRates script Include :

var RMRates = Class.create();
RMRates.prototype = {
	initialize: function(resourcePlan) {
		this.resourcePlan = resourcePlan;
	},
	
	getDailyRatesForPlan: function(startDate, endDate) {
		if (JSUtil.nil(startDate))
			startDate = this.resourcePlan.getValue('start_date');
		if (JSUtil.nil(endDate))
			endDate = this.resourcePlan.getValue('end_date');
		
		return this.getDailyRates(this.resourcePlan.getValue('user_resource'), startDate, endDate);
	},
	
	getDailyRatesForUser: function(userId, startDate, endDate) {
		if (JSUtil.nil(startDate))
			startDate = this.resourcePlan.getValue('start_date');
		if (JSUtil.nil(endDate))
			endDate = this.resourcePlan.getValue('end_date');
		
		return this.getDailyRates(userId, startDate, endDate);
	},
	
	getDailyRates: function(userId, startDate, endDate) {
		var useBudgetReferenceRates = gs.getProperty('com.snc.resource_management.use_budget_reference_rates', 'false') === 'true';
		if (this.getRateModel()) {
			useBudgetReferenceRates = true; //Always use budget reference rates for Rate Model
			return (new RMRateModelApi(this.resourcePlan, this.rateModel, useBudgetReferenceRates).getDailyRates(userId, startDate, endDate));
		} else
		return this.getResourceDailyRates(userId, startDate, endDate, useBudgetReferenceRates);
	},
	
	getRateModel: function() {
		if (JSUtil.nil(this.rateModel))
		if (JSUtil.notNil(this.resourcePlan.task)) {
			var taskRecord;
		if (JSUtil.notNil(this.resourcePlan.top_task))
				taskRecord = this.resourcePlan.top_task.getRefRecord();
			else
				taskRecord = this.resourcePlan.task.getRefRecord();
		if (taskRecord.isValidField('rate_model')&&JSUtil.notNil(taskRecord.getValue('rate_model')))
				this.rateModel = taskRecord.getValue('rate_model');
			else
				this.rateModel ='5c9daaf3dbaed8102deec55305961952'; //----suraj-----//
		} else if (this.resourcePlan.isValidField('rate_model') && JSUtil.notNil(this.resourcePlan.getValue('rate_model')))
			this.rateModel = this.resourcePlan.getValue('rate_model');
				
		return this.rateModel;
	},
	
	//Uses Labor rate card/Role rates/Group Rates()
	getResourceDailyRates: function(userId, startDate, endDate, useBudgetReferenceRates) {
		var rateArray = this.getResourceRateObjectArray(userId, startDate, endDate, useBudgetReferenceRates);
		return (new DailyRates(rateArray));
	},
	
	getResourceRateObjectArray: function(userId, startDate, endDate, useBudgetReferenceRates) {
		if (JSUtil.notNil(userId) || this.resourcePlan.resource_type == 'user') {
			if (JSUtil.nil(userId))
				userId = this.resourcePlan.getValue('user_resource');
			var laborRates = new RMLaborRates();
			return laborRates.getUserRateObjectArray(userId, startDate, endDate, useBudgetReferenceRates);
		}
		
		if (!this.resourcePlan.role.nil()) {
			var roleGr = this.resourcePlan.role.getRefRecord();
			if (roleGr.hourly_rate.getCurrencyValue() > 0)
				return RateUtils.getRateObjectArrayFromRate(roleGr.hourly_rate.getCurrencyValue(), roleGr.hourly_rate.getCurrencyCode(), roleGr.hourly_rate.getReferenceValue(), startDate, endDate, useBudgetReferenceRates);
		}
		
		if (!this.resourcePlan.group_resource.nil()) {
			var groupGr = this.resourcePlan.group_resource.getRefRecord();
			if (groupGr.hourly_rate.getCurrencyValue() > 0)
				return RateUtils.getRateObjectArrayFromRate(groupGr.hourly_rate.getCurrencyValue(), groupGr.hourly_rate.getCurrencyCode(), groupGr.hourly_rate.getReferenceValue(), startDate, endDate, useBudgetReferenceRates);
		}
		
		//default rate from property com.snc.time_card.default_rate
		return RateUtils.getDefaultRateObjectArray(startDate, endDate);
	},
	
	//ToBeDeprecated
	getHourlyRateForPlan: function(gr) {
		if (gr.resource_type == 'user') {
			var userRate = this.getUserHourlyRateById(gr.getValue('user_resource'));
			return userRate;
		}
		
		if (!gr.role.nil()) {
			var roleRate = this.getRoleHourlyRate(gr.role.getRefRecord());
			if (!gs.nil(roleRate) && roleRate > 0) {
				return roleRate;
			}
		}
		
		var groupRate = this.getGroupHourlyRate(gr.group_resource.getRefRecord());
		if (!gs.nil(groupRate) && groupRate > 0) {
			return groupRate;
		}
		
		var hourlyRate = gs.getProperty("com.snc.time_card.default_rate", 0);
		return hourlyRate;
	},
	
	//ToBeDeprecated
	getPlannedHourlyRateForPlan: function(gr, allocationStartDate) {
		
		// for pre-London customers we want to user platforms daily exchange rates during planning.
		if(gs.getProperty('com.snc.resource_management.use_budget_reference_rates', 'false') != 'true')
			return this.getHourlyRateForPlan(gr);
		if (gr.resource_type == 'user') {
			var userRate = this.getPlannedUserHourlyRateById(gr.getValue('user_resource'), allocationStartDate);
			return userRate;
		}
		
		if (!gr.role.nil()) {
			var roleRate = this.getPlannedRoleHourlyRate(gr.role.getRefRecord(), allocationStartDate);
			if (!gs.nil(roleRate) && roleRate > 0) {
				return roleRate;
			}
		}
		
		var groupRate = this.getPlannedGroupHourlyRate(gr.group_resource.getRefRecord(), allocationStartDate);
		if (!gs.nil(groupRate) && groupRate > 0) {
			return groupRate;
		}
		
		var hourlyRate = gs.getProperty("com.snc.time_card.default_rate", 0);
		return hourlyRate;
	},
	
	getPlannedUserHourlyRateById: function(userId, allocationStartDate) {
		var laborRates = new RMLaborRates();
		var userRate = laborRates.getPlannedUserRate(userId, allocationStartDate);
		return userRate;
	},
	
	getPlannedGroupHourlyRate: function(gr, allocationStartDate) {
		gs.log("getPlannedGroupHourlyRate: "+gr.hourly_rate.getCurrencyValue() +" : "+gr.hourly_rate.getCurrencyCode());
		var groupRate = gr.hourly_rate.nil() ? 0 : (this.getPlannedFunctionalRate(gr.hourly_rate.getCurrencyValue(), gr.hourly_rate.getCurrencyCode(),allocationStartDate));
		return groupRate;
	},
	
	getPlannedRoleHourlyRate: function(gr, allocationStartDate) {
		var roleRate = gr.hourly_rate.nil() ? 0 : (this.getPlannedFunctionalRate( gr.hourly_rate.getCurrencyValue(), gr.hourly_rate.getCurrencyCode(), allocationStartDate));
		return roleRate;
	},
	
	getPlannedFunctionalRate: function(rate, currency, allocationStartDate) {
		if(typeof SNC.FMCurrency != 'undefined') {
			var currencyService = new SNC.FMCurrency();
			var globalCurrency = currencyService.getGlobalCurrencyCode();
			if(globalCurrency != currency)
				return currencyService.convertAmountWithFp(rate,currency, globalCurrency, allocationStartDate);
		}
		return rate;
	},
	
	getUserHourlyRateById: function(userId) {
		var laborRates = new RMLaborRates();
		var userRate = laborRates.getUserRate(userId);
		return userRate;
	},
	
	getGroupHourlyRate: function(gr) {
		var groupRate = gr.hourly_rate.nil() ? 0 : gr.hourly_rate.getReferenceValue();
		return groupRate;
	},
	
	getRoleHourlyRate: function(gr) {
		var roleRate = gr.hourly_rate.nil() ? 0 : gr.hourly_rate.getReferenceValue();
		return roleRate;
	},
	
	type: 'RMRates'
};

can i expect any updates ?