Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Timetracker version 4.7.5 or higher is required to access this API

Wage manager permission required for the user this service

A cost rate with a date can be added to a user via this service.

API

package org.everit.jira.reporting.service.costrate;

import java.time.LocalDate;
import java.util.List;

/**
 * Public User Cost Service.
 */
public interface UserCostService {

  /**
   * Add cost rate. Requires Wage Manager permission.
   *
   * @param userKey
   *          the user key
   * @param validFromIncl
   *          the from date (inclusive).
   * @param costRate
   *          the cost rate.
   */
  void addCostRate(String userKey, LocalDate validFromIncl, double costRate);

  /**
   * Delete cost rate. Requires Wage Manager permission.
   *
   * @param costRateId
   *          the id of cost rate.
   */
  void deleteCostRate(long costRateId);

  /**
   * List all cost rates for the specific users. Requires Wage Manager permission, else returns an empty list.
   *
   * @param userKey
   *          the user key.
   * @return list of cost rates.
   */
  List<CostRateInfo> listCostRates(String userKey);

  /**
   * Update cost rate. Requires Wage Manager permission.
   *
   * @param costRateId
   *          the id of cost rate.
   * @param userKey
   *          the user key
   * @param validFromIncl
   *          the from date (inclusive).
   * @param costRate
   *          the cost rate.
   */
  void updateCostRate(long costRateId, String userKey, LocalDate validFromIncl, double costRate);
}

Example

import com.onresolve.scriptrunner.runner.customisers.PluginModule;
import java.time.LocalDate;
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
import org.everit.jira.reporting.service.costrate.CostRateInfo;
import org.everit.jira.reporting.service.costrate.UserCostService;
import java.util.Arrays;


@WithPlugin("org.everit.jira.timetracker.plugin")

@PluginModule
UserCostService userCostService;


List<CostRateInfo> costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates);

LocalDate now = LocalDate.now();
userCostService.addCostRate("douglas.arnold@everit.biz", now, (double) 5.0);

costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates);

CostRateInfo costRateInfo = costRates.get(0);
userCostService.updateCostRate(costRateInfo.costRateId, costRateInfo.userKey, costRateInfo.validFromIncl, (double) 2.0);

costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates);

costRateInfo = costRates.get(0);
userCostService.deleteCostRate(costRateInfo.costRateId);

costRates = userCostService.listCostRates("douglas.arnold@everit.biz");
log.error(costRates)

  • No labels