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

class FixTotalReqEffort(ChangeDTPPacket):
    '''Fixes a error message while creating status report due to a wrong value range'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 10535

    def fix(self, runner):
        new_value = 'DI029256+DI029255'
        old_value = 'DI026256+DI029255'
        
        self.log('Get value range of DI058023')
        
        record = self.get_record(412, ['058023'], [27352])
        if not record:
            self.log('Record not found')
            return self.fail()              

        if not self.verify_value(record, 'valuerange', new_value):
            self.log('Changing value range of DI058023  to correct  value')           

            if not self.change_value(record, 'valuerange', old_value, new_value):
                return self.fail()

        return self.success()