joniles / mpxj

Primary repository for MPXJ library
http://www.mpxj.org/
GNU Lesser General Public License v2.1
240 stars 101 forks source link

[BUG] [RUBY] - MS Project import task relations uncorrectly #707

Closed pedrohcarvalhom closed 1 month ago

pedrohcarvalhom commented 1 month ago

Hi, I'm having a trouble when importing a ms project file using mpxj.

Basically, the lag of one relation between tasks is showing 144 thousand days of lag. However, in the ms project file they have 5 days of lag.

This is the attribute_value from the successor task:

{
                          "start" => "2024-08-01T09:00:00.0",
           "leveling_delay_units" => "ed",
                           "name" => "Elaboração de memorial",
                            "wbs" => "3.3",
                "constraint_type" => "AS_SOON_AS_POSSIBLE",
                    "total_slack" => 9561600,
                             "id" => 18,
                       "priority" => 500,
                       "duration" => 864000,
             "remaining_duration" => 864000,
                    "early_start" => "2024-08-01T09:00:00.0",
                   "early_finish" => "2024-09-11T18:00:00.0",
                     "late_start" => "2025-11-10T09:00:00.0",
                    "late_finish" => "2025-12-22T09:00:00.0",
                   "predecessors" => [
        [0] {
                 "unique_id" => 5,
            "task_unique_id" => 22,
                       "lag" => 144000,
                      "type" => "SS"
        }
    ],
                     "successors" => [
        [0] {
                 "unique_id" => 6,
            "task_unique_id" => 54,
                      "type" => "FF"
        },
        [1] {
                 "unique_id" => 786,
            "task_unique_id" => 36,
                      "type" => "FS"
        }
    ],
                  "outline_level" => 2,
                      "unique_id" => 44,
                        "created" => "2024-04-16T11:20:00.0",
                 "outline_number" => "3.3",
             "fixed_cost_accrual" => "PRORATED",
             "leveling_can_split" => true,
              "level_assignments" => true,
                    "start_slack" => 9561600,
                   "finish_slack" => 9561600,
               "summary_progress" => "2024-08-01T09:00:00.0",
                           "guid" => "32b0b853-f918-ef11-952f-68545a78c1e7",
                         "active" => true,
                      "task_mode" => "MANUALLY_SCHEDULED",
    "baseline_fixed_cost_accrual" => "PRORATED",
             "scheduled_duration" => 864000,
               "scheduled_finish" => "2024-09-11T18:00:00.0",
                "scheduled_start" => "2024-08-01T09:00:00.0",
                "manual_duration" => 864000,
          "parent_task_unique_id" => 6,
           "recalc_outline_codes" => true,
                       "expanded" => true,
                         "finish" => "2024-09-11T18:00:00.0"
}

and this is the predecessor task:

{
                          "start" => "2024-07-25T09:00:00.0",
           "leveling_delay_units" => "ed",
                           "name" => "Elaboração do Produto",
                            "wbs" => "3.2",
                "constraint_type" => "AS_SOON_AS_POSSIBLE",
                    "total_slack" => 11433600,
                             "id" => 17,
                       "priority" => 500,
                       "duration" => 864000,
             "remaining_duration" => 864000,
                    "early_start" => "2024-07-25T09:00:00.0",
                   "early_finish" => "2024-09-04T18:00:00.0",
                     "late_start" => "2026-02-02T09:00:00.0",
                    "late_finish" => "2026-03-13T18:00:00.0",
                   "predecessors" => [
        [0] {
                 "unique_id" => 8,
            "task_unique_id" => 45,
                      "type" => "FS"
        }
    ],
                     "successors" => [
        [0] {
                 "unique_id" => 5,
            "task_unique_id" => 44,
                       "lag" => 144000,
                      "type" => "SS"
        }
    ],
                  "outline_level" => 2,
                      "unique_id" => 22,
                        "created" => "2024-04-16T11:03:00.0",
                 "outline_number" => "3.2",
             "fixed_cost_accrual" => "PRORATED",
             "leveling_can_split" => true,
              "level_assignments" => true,
                    "start_slack" => 11433600,
                   "finish_slack" => 11433600,
               "summary_progress" => "2024-07-25T09:00:00.0",
                           "guid" => "23b0b853-f918-ef11-952f-68545a78c1e7",
                         "active" => true,
                      "task_mode" => "MANUALLY_SCHEDULED",
    "baseline_fixed_cost_accrual" => "PRORATED",
             "scheduled_duration" => 864000,
               "scheduled_finish" => "2024-09-04T18:00:00.0",
                "scheduled_start" => "2024-07-25T09:00:00.0",
                "manual_duration" => 864000,
          "parent_task_unique_id" => 6,
           "recalc_outline_codes" => true,
                       "expanded" => true,

and this is the task in ms project (its in brazilian portuguese, but the important is the lag circled)

msproject

as u can see, the lag is not right. I dont know if is something like the unit of the lag or something else.

joniles commented 1 month ago

Olá! Thanks for opening the issue. The problem you are seeing is that the default time units for exported durations is seconds, so 144000 second is 5 days.

There are some notes here on the Ruby API: https://www.rubydoc.info/gems/mpxj/12.10.2/MPXJ/Reader#read-class_method you can pass the time_units argument to set your preferred time units in the output file.

Hope that helps!

Jon

pedrohcarvalhom commented 1 month ago

Thanks, that worked