It appears that the cost calculation for FixedDuration type tasks when a WorkContour is set is not calculating correctly.
I have an example Microsoft project with only a small number of tasks. Each task is assigned WorkContour of Back Loaded. If I read the project and adjust each task’s duration via code by 10 days, the Fixed Work and Fixed Units calculated Cost match that of those provided by Microsoft Project, if the same changes are made directly.
Project m_CalcProject_Original = new Project(@"C:\Examples_FixedDurationIssue.mpp");
ChildTasksCollector m_coll = new ChildTasksCollector();
TaskUtils.Apply(m_CalcProject_Original.RootTask, m_coll, 0);
List<Aspose.Tasks.Task> m_Tasks = m_coll.Tasks;
Console.WriteLine("BEFORE");
foreach (Aspose.Tasks.Task x in m_Tasks)
{
Console.WriteLine("Name: {0} Duration: {1} Type: {2} Work: {3} Cost: {4}", x.Get(Tsk.Name), x.Get(Tsk.Duration), x.Get(Tsk.Type), x.Get(Tsk.Work), x.Get(Tsk.Cost));
x.Set(Tsk.Duration, m_CalcProject_Original.GetDuration(x.Get(Tsk.Duration).ToDouble() + 10));
}
m_CalcProject_Original.Recalculate();
Console.WriteLine("");
Console.WriteLine("AFTER");
foreach (Aspose.Tasks.Task x in m_Tasks)
{
Console.WriteLine("Name: {0} Duration: {1} Type: {2} Work: {3} Cost: {4}", x.Get(Tsk.Name), x.Get(Tsk.Duration), x.Get(Tsk.Type), x.Get(Tsk.Work), x.Get(Tsk.Cost));
}
I’m also including a sample Microsoft project file that has the complete set of types and work contours. It appears that only the Fixed Duration types are calculating incorrectly.
MSProject_GanttView.jpg (162.9 KB)
MSProject_TaskUsage.jpg (171.9 KB)
SampleProgram.jpg (156.1 KB)
Examples_FixedDurationIssue.zip (140.9 KB)
Examples.zip (41.5 KB)