...
Code Block |
---|
import com.onresolve.scriptrunner.runner.customisers.PluginModule; import java.time.LocalDate; import java.time.temporal.ChronoUnit; 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 cost rates for a user. List<CostRateInfo> costRates = userCostService.listCostRates("douglas.arnold@everit.biz"); // log.errorinfo(costRates); // add cost rate for a user LocalDate now = LocalDate.now(); userCostService.addCostRate("douglas.arnold@everit.biz", now, (double) 5.0); costRates = userCostService.listCostRates("douglas.arnold@everit.biz"); // log.errorinfo(costRates); // update cost rate (change cost rate for a user) CostRateInfo costRateInfo = costRates.get(0); userCostService.updateCostRate(costRateInfo.costRateId, costRateInfo.userKey, costRateInfo.validFromIncl, (double) 2.0); costRates = userCostService.listCostRates("douglas.arnold@everit.biz"); // log.info(costRates); // update cost rate (change cost rate and from date for a user) LocalDate nowMinusTenDays = LocalDate.now() .minus(10, ChronoUnit.DAYS); costRateInfo = costRates.get(0); userCostService.updateCostRate(costRateInfo.costRateId, costRateInfo.userKey, nowMinusTenDays, (double) 1.0); costRates = userCostService.listCostRates("douglas.arnold@everit.biz"); // log.errorinfo(costRates); // delete cost rate costRateInfo = costRates.get(0); userCostService.deleteCostRate(costRateInfo.costRateId); costRates = userCostService.listCostRates("douglas.arnold@everit.biz"); // log.errorinfo(costRates); |