# -*- coding: utf-8 -*-
from ppms.migration.packet import *

class FixMSPImport(ChangeDTPPacket):
    '''Fix an error with the Microsoft Project import function'''
    wi_number = 9953
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY

    def fix(self, runner):
        failures = 0
        for di_num in ['059559', '059560']:
            record = self.get_record(412, [di_num], [2461])
            if not self.change_value(record, 'sql', 0, 1):
                failures += 1

        if failures:
            return self.fail()

        return self.success()
