# -*- coding: utf-8 -*-
from ppms.migration import ChangeDTPPacket, PacketCategory, MaxVersionDependency, VersionType


class ChangeSummaryTypeValueInPlanningObjects(ChangeDTPPacket):
    '''Change the value of summary type for DI 023220 in DA 050729 in MOD 0099RB.
    This is needed to fix a upcoming error when you focus this Modul the first time'''
    
    wi_number = 14933  # The workitem number this packet belongs to. Only relevant for packets by PLANTA
    version = 1
    done_after_success = True  # Sets the "Erledigt" flag after running successfully
    run_on_startup = True  # Runs this migration packet when the server is started in migration mode
    category = PacketCategory.CATEGORY_MANDATORY  # Categorizes the packet
    
    def get_dependencies(self):
        return MaxVersionDependency(version='39.4', version_type=VersionType.CUSTOMIZING)
        
    def fix(self, runner):
        
        OLD_VALUE = 2
        NEW_VALUE = 0
    
        record = self.get_record(411, ['050729',728470], ['summary_type'])
        if not self.change_value(record, 'summary_type', OLD_VALUE, NEW_VALUE):
            return self.fail()

        return self.success()