Commit d67cc6e3 authored by Kurt Maute's avatar Kurt Maute

Fix for Cost and Slack calculations. Cost calc on summary tasks now equal to...

Fix for Cost and Slack calculations.  Cost calc on summary tasks now equal to sum of child tasks.  Slack calc now uses default calendar and ignores assignments.
parent 311faf2e
......@@ -1917,6 +1917,35 @@ mrp_project_reschedule (MrpProject *project)
mrp_task_manager_recalc (project->priv->task_manager, TRUE);
}
/**
* mrp_project_calculate_summary_duration:
* @project: an #MrpProject
* @task: an #MrpTask
* @start: a start time, or if %-1, the task start time is to be used
* @finish: a finish time
*
* Calculates the time needed to achieve the given start and finish time,
* ignoring allocated resources' calendars (summary tasks should ignore
* their own resource assignments)
*
* Return value: The calculated duration.
**/
gint
mrp_project_calculate_summary_duration (MrpProject *project,
MrpTask *task,
mrptime start,
mrptime finish)
{
g_return_val_if_fail (MRP_IS_PROJECT (project), 0);
g_return_val_if_fail (MRP_IS_TASK (task), 0);
g_return_val_if_fail (start == -1 || start <= finish, 0);
g_return_val_if_fail (finish >= 0, 0);
return mrp_task_manager_calculate_summary_duration (
project->priv->task_manager,
task, start, finish);
}
/**
* mrp_project_calculate_task_work:
* @project: an #MrpProject
......
......@@ -121,6 +121,10 @@ void mrp_project_task_traverse (MrpProject *pro
MrpTaskTraverseFunc func,
gpointer user_data);
void mrp_project_reschedule (MrpProject *project);
gint mrp_project_calculate_summary_duration (MrpProject *project,
MrpTask *task,
mrptime start,
mrptime finish);
gint mrp_project_calculate_task_work (MrpProject *project,
MrpTask *task,
mrptime start,
......
......@@ -1630,18 +1630,22 @@ mrp_task_get_cost (MrpTask *task)
return priv->cost;
}
/* summary task cost calc */
child = mrp_task_get_first_child (task);
while (child) {
total += mrp_task_get_cost (child);
child = mrp_task_get_next_sibling (child);
}
assignments = mrp_task_get_assignments (task);
for (l = assignments; l; l = l->next) {
resource = mrp_assignment_get_resource (l->data);
if (child) {
while (child) {
total += mrp_task_get_cost (child);
child = mrp_task_get_next_sibling (child);
}
} else {
/* non summary task cost calc */
assignments = mrp_task_get_assignments (task);
for (l = assignments; l; l = l->next) {
resource = mrp_assignment_get_resource (l->data);
mrp_object_get (resource, "cost", &cost, NULL);
total += mrp_assignment_get_units (l->data) * priv->duration * cost / (3600.0 * 100);
mrp_object_get (resource, "cost", &cost, NULL);
total += mrp_assignment_get_units (l->data) * priv->duration * cost / (3600.0 * 100);
}
}
priv->cost = total;
......
......@@ -844,9 +844,11 @@ gantt_model_get_value (GtkTreeModel *tree_model,
t2 = mrp_task_get_latest_finish (task);
project = mrp_object_get_project (MRP_OBJECT (task));
/* We don't support negative slack yet. */
/* We don't support negative slack */
if (t2 >= t1) {
duration = mrp_project_calculate_task_work (
/* use summary duration calc since we want to use
* the project calendar and ignore resource assignments */
duration = mrp_project_calculate_summary_duration (
project, task, t1, t2);
} else {
duration = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment