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

class ChangePageBreakValueRange(ChangeDTPPacket,SQLPacket):
    """Add value "4" to listbox and value range of DI001583 "Page Break" """
    version = 1
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 13434
    
    dml_file = 'wi13434_change_pagebreak.sql'

    def get_dependencies(self):
        return MaxVersionDependency(version='39.4', version_type=VersionType.CUSTOMIZING)

    def fix(self, runner):
        record = self.get_record(dt_num=412, key_list=['001583'], di_list=['valuerange'])

        if not self.change_value(record=record, attribute='valuerange', old_value='0,1,2,3', new_value='0,1,2,3,4'):
            return self.fail('Could not change the valuerange, maybe there was a individual customizing')

        self.apply_dml_file(self.sql_planta_de_dbms, self.dml_file)
        
        return self.success()