# -*- coding: utf-8 -*-

from ppms.migration import SQLPacket, PacketCategory, MinVersionDependency, MaxVersionDependency, VersionType

class FixProgramBudgetForPortfolioBaseline(SQLPacket):
    """Fix program budget values, that are essential for the display of depending portfolio baseline
    """

    version = 1
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 13012


    dml_file = 'wi13012_fix_program_budget_for_pf_baseline.sql'


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


    def fix(self, runner):
        try:
            # execute sql file, that does the job
            self.apply_dml_file(self.sql_planta_de_ansi, self.dml_file)

            return self.success()
        except Exception as e:
            self.fail(e)
