BrightSide Workbench Full Report + Source Code
ResourceUsageValuation.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.erp.task;
20 
21 import org.turro.erp.entity.AptitudeDegree;
22 import org.turro.erp.entity.HumanResource;
23 import org.turro.erp.entity.Resource;
24 
29 public class ResourceUsageValuation implements IUsageValuation {
30 
31  private HumanResource humanResource;
32  private Resource resource;
33  private AptitudeDegree aptitudeDegree, aptitudeAssesment;
34  private double dedication;
35 
36  public ResourceUsageValuation(HumanResource humanResource, Resource resource,
37  AptitudeDegree aptitudeDegree, AptitudeDegree aptitudeAssesment,
38  double dedication) {
39  this.humanResource = humanResource;
40  this.resource = resource;
41  this.aptitudeDegree = aptitudeDegree;
42  this.aptitudeAssesment = aptitudeAssesment;
43  this.dedication = dedication;
44  }
45 
46  @Override
47  public double getUnitCost() {
48  double cost = 0.0;
49  AptitudeDegree aptitude = aptitudeAssesment != null ?
50  aptitudeAssesment : aptitudeDegree;
51  if(humanResource != null && aptitude != null) {
52  if(resource != null) {
53  if(humanResource.isInternal() && resource.isInternal()) {
54  cost = resource.getCostHour() + aptitude.getCost() + (humanResource.getCostHour() * dedication);
55  } else if(humanResource.isInternal()) {
56  cost = (resource.getCostHour() > 0.0 ? resource.getCostHour() : aptitude.getCost()) +
57  (humanResource.getCostHour() * dedication);
58  } else if(resource.isInternal()) {
59  cost = (resource.getCostHour() > 0.0 ? resource.getCostHour() : aptitude.getCost()) +
60  (humanResource.getCostHour() * dedication);
61  } else {
62  cost = (resource.getCostHour() > 0.0 ? resource.getCostHour() : aptitude.getCost());
63  }
64  } else {
65  if(humanResource.isInternal()) {
66  cost = aptitude.getCost() + (humanResource.getCostHour() * dedication);
67  } else {
68  cost = (humanResource.getCostHour() > 0.0 ? (humanResource.getCostHour() * dedication) : (aptitude.getCost() * dedication));
69  }
70  }
71  }
72  return cost;
73  }
74 
75  @Override
76  public double getUnitPrice() {
77  double price = 0.0;
78  AptitudeDegree aptitude = aptitudeAssesment != null ?
79  aptitudeAssesment : aptitudeDegree;
80  if(humanResource != null && aptitude != null) {
81  if(resource != null) {
82  if(humanResource.isInternal() && resource.isInternal()) {
83  price = (resource.getPriceHour() > 0.0 ? resource.getPriceHour() : aptitude.getPrice());
84  } else if(humanResource.isInternal()) {
85  price = (resource.getPriceHour() > 0.0 ? resource.getPriceHour() : aptitude.getPrice());
86  } else if(resource.isInternal()) {
87  price = (resource.getPriceHour() > 0.0 ? resource.getPriceHour() : aptitude.getPrice());
88  } else {
89  price = (resource.getPriceHour() > 0.0 ? resource.getPriceHour() : aptitude.getPrice());
90  }
91  } else {
92  if(humanResource.isInternal()) {
93  price = (humanResource.getPriceHour() > 0.0 ? humanResource.getPriceHour() : aptitude.getPrice());
94  } else {
95  price = (humanResource.getPriceHour() > 0.0 ? humanResource.getPriceHour() : aptitude.getPrice());
96  }
97  }
98  }
99  return price;
100  }
101 }
ResourceUsageValuation(HumanResource humanResource, Resource resource, AptitudeDegree aptitudeDegree, AptitudeDegree aptitudeAssesment, double dedication)