コード例 #1
0
def pursi_rule(base_filters, price, kurssi_price=0):
    return FirstRule([
        FlightRule(0, base_filters + F_PURSIK,
                   u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
        FlightRule(
            kurssi_price, base_filters + F_KURSSIK,
            u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"
        ),
        FlightRule(price, base_filters)
    ])
コード例 #2
0
def make_rules(ctx=BillingContext()):
    ACCT_PURSI_KEIKKA = 3220
    ACCT_TOW = 3130
    ACCT_DDS = 3101
    ACCT_CAO = 3100
    ACCT_TOWING = 3170 # Muut lentotoiminnan tulot
    ACCT_PURSI_INSTRUCTION = 3470 # Muut tulot koulutustoiminnasta
    ACCT_KALUSTO = 3010
    ACCT_LASKUTUSLISA = 3610 # Hallinnon tulot

    ID_KM_2014 = u"kausimaksu_tot_2014"
    ID_KM_P_2014 = u"kausimaksu_pursi_2014"
    ID_KM_M_2014 = u"kausimaksu_motti_2014"

    ID_KM_2015 = u"kausimaksu_tot_2015"
    ID_KM_P_2015 = u"kausimaksu_pursi_2015"
    ID_KM_M_2015 = u"kausimaksu_motti_2015"

    ID_KM_2016 = u"kausimaksu_tot_2016"
    ID_KM_P_2016 = u"kausimaksu_pursi_2016"
    ID_KM_M_2016 = u"kausimaksu_motti_2016"

    # Added 2017-10-09:
    ID_KM_2017 = u"kausimaksu_tot_2017"
    ID_KM_P_2017 = u"kausimaksu_pursi_2017"
    ID_KM_M_2017 = u"kausimaksu_motti_2017"

    # Added 2018-11-07:
    ID_KM_2018 = u"kausimaksu_tot_2018"
    ID_KM_P_2018 = u"kausimaksu_pursi_2018"
    ID_KM_M_2018 = u"kausimaksu_motti_2018"
    
    # Added 2019-10-08:
    ID_KM_2019 = u"kausimaksu_tot_2019"
    ID_KM_P_2019 = u"kausimaksu_pursi_2019"
    ID_KM_M_2019 = u"kausimaksu_motti_2019"
    
    ID_PK_2014 = u"pursikönttä_2014"
    ID_PK_2015 = u"pursikönttä_2015"
    ID_PK_2016 = u"pursikönttä_2016"
    ID_PK_2017 = u"pursikönttä_2017" # Added 2017-10-09
    ID_PK_2018 = u"pursikönttä_2018" # Added 2018-11-07
    ID_PK_2019 = u"pursikönttä_2019" # Added 2019-10-08

    ID_KK_2014 = u"kurssikönttä_2014"
    ID_KK_2015 = u"kurssikönttä_2015"
    ID_KK_2016 = u"kurssikönttä_2016"
    ID_KK_2017 = u"kurssikönttä_2017" # Added 2017-10-09
    ID_KK_2018 = u"kurssikönttä_2018" # Added 2018-11-07
    ID_KK_2019 = u"kurssikönttä_2019" # Added 2019-10-08

    F_PAST = [PeriodFilter(Period(dt.date(2010,1,1), dt.date(2013,12,31)))]

    F_2014 = [PeriodFilter(Period.full_year(2014))]
    F_FK = [AircraftFilter("650")]
    F_FM = [AircraftFilter("787")]
    F_FQ = [AircraftFilter("733")]
    F_FY = [AircraftFilter("883")]
    F_FI = [AircraftFilter("1035")]
    F_DG = [AircraftFilter("952")]
    F_TK = [AircraftFilter("TK")]
    F_HB = [AircraftFilter("755")]
    F_DDS = [AircraftFilter("DDS")]
    F_CAO = [AircraftFilter("CAO")]
    F_TOW = [AircraftFilter("TOW")]
    F_MOTTI = [AircraftFilter("DDS","CAO","TOW")]
    F_PURTSIKKA = [AircraftFilter("650","787","733","883","952")]
    F_KAIKKI_KONEET = [AircraftFilter("DDS","CAO","TOW","650","787","733","883","952")]
    F_PURSIK = [SinceDateFilter(ctx, ID_PK_2014)]
    F_KURSSIK = [SinceDateFilter(ctx, ID_KK_2014)]
    F_LASKUTUSLISA = [InvoicingChargeFilter()]

    F_2015 = [PeriodFilter(Period.full_year(2015))]
    F_PURTSIKKA_2015 = [AircraftFilter("650","787","733","883","952","TK")]
    F_KAIKKI_KONEET_2015 = [AircraftFilter("DDS","CAO","TOW","650","787","733","883","952","TK")]
    F_PURSIK_2015 = [SinceDateFilter(ctx, ID_PK_2015)]
    F_KURSSIK_2015 = [SinceDateFilter(ctx, ID_KK_2015)]

    F_2016 = [PeriodFilter(Period.full_year(2016))]
    F_PURTSIKKA_2016 = [AircraftFilter("650","787","733","883","952","755")]
    F_KAIKKI_KONEET_2016 = [AircraftFilter("TOW","650","787","733","883","952","755")]
    F_PURSIK_2016 = [SinceDateFilter(ctx, ID_PK_2016)]
    F_KURSSIK_2016 = [SinceDateFilter(ctx, ID_KK_2016)]
    
     # Added 2017-10-09:
    F_2017 = [PeriodFilter(Period.full_year(2017))]
    F_PURTSIKKA_2017 = [AircraftFilter("650","787","733","883","952")]
    F_KAIKKI_KONEET_2017 = [AircraftFilter("TOW","650","787","733","883","952")]
    F_PURSIK_2017 = [SinceDateFilter(ctx, ID_PK_2017)]
    F_KURSSIK_2017 = [SinceDateFilter(ctx, ID_KK_2017)]

    # Added 2018-11-07:
    F_2018 = [PeriodFilter(Period.full_year(2018))]
    F_PURTSIKKA_2018 = [AircraftFilter("650","787","733","883","952")]
    F_KAIKKI_KONEET_2018 = [AircraftFilter("TOW","650","787","733","883","952")]
    F_PURSIK_2018 = [SinceDateFilter(ctx, ID_PK_2018)]
    F_KURSSIK_2018 = [SinceDateFilter(ctx, ID_KK_2018)]
    
    # Added 2019-10-08:
    F_2019 = [PeriodFilter(Period.full_year(2019))]
    F_PURTSIKKA_2019 = [AircraftFilter("650","787","733","883","952","1035")]
    F_KAIKKI_KONEET_2019 = [AircraftFilter("TOW","650","787","733","883","952","1035")]
    F_PURSIK_2019 = [SinceDateFilter(ctx, ID_PK_2019)]
    F_KURSSIK_2019 = [SinceDateFilter(ctx, ID_KK_2019)]


    def pursi_rule(base_filters, price, kurssi_price = 0, package_price = 0):
        return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                          FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                          FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])

    def pursi_rule_2015(base_filters, price, kurssi_price = 0, package_price = 0):
        return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK_2015, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                          FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK_2015, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                          FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])

    def pursi_rule_2016(base_filters, price, kurssi_price = 0, package_price = 0):
        return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK_2016, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                          FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK_2016, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                          FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])

    # Added 2017-10-09:
    def pursi_rule_2017(base_filters, price, kurssi_price = 0, package_price = 0):
        return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK_2017, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                          FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK_2017, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                          FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])

    # Added 2018-11-07:
    def pursi_rule_2018(base_filters, price, kurssi_price = 0, package_price = 0):
        return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK_2018, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                          FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK_2018, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                          FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])
                          
    # Added 2019-10-08:
    def pursi_rule_2019(base_filters, price, kurssi_price = 0, package_price = 0):
        return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK_2019, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                          FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK_2019, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                          FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])

    rules_past = [
        # Normal simple events from the past are OK
        SimpleRule(F_PAST)
    ]

    rules_2014 = [
        FlightRule(171, ACCT_DDS, F_DDS + F_2014),
        FlightRule(134, ACCT_CAO, F_CAO + F_2014),
        FlightRule(146, ACCT_TOW, F_TOW + [PeriodFilter(Period(dt.date(2014, 1, 1), dt.date(2014, 3, 31)))]),
        # Variable price for TOW in the second period, based on purpose of flight
        FirstRule([FlightRule(124, ACCT_TOWING, F_TOW + [PeriodFilter(Period(dt.date(2013, 4, 1), dt.date(2014, 12, 31))), TransferTowFilter()], u"Siirtohinaus, %(duration)d min"),
                   FlightRule(104, ACCT_TOW, F_TOW + [PeriodFilter(Period(dt.date(2013, 4, 1), dt.date(2014, 12, 31)))])
               ]),

        pursi_rule(F_2014 + F_FK, 15),
        pursi_rule(F_2014 + F_FM, 25, 10),
        pursi_rule(F_2014 + F_FQ, 25),
        pursi_rule(F_2014 + F_FY, 32, 17),
        pursi_rule(F_2014 + F_DG, 40),

        # Koululentomaksu
        FlightRule(lambda ev: 5, ACCT_PURSI_INSTRUCTION, F_PURTSIKKA + F_2014 + [PurposeFilter("KOU")], "Koululentomaksu, %(aircraft)s"),

        CappedRule(ID_KM_2014, 90, ctx,
                   AllRules([CappedRule(ID_KM_P_2014, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, [PeriodFilter(Period.full_year(2014)),
                                                              AircraftFilter("650", "733", "787", "883", "952")],
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min")),
                              CappedRule(ID_KM_M_2014, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, [PeriodFilter(Period.full_year(2014)),
                                                         AircraftFilter("DDS", "CAO", "TOW"),
                                                         NegationFilter(TransferTowFilter())], # No kalustomaksu for transfer tows
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min"))])),

        # Normal simple events
        FirstRule([SetDateRule(ID_PK_2014, ctx, SimpleRule(F_2014 + [ItemFilter(u".*[pP]ursikönttä.*")])),
                   SetDateRule(ID_KK_2014, ctx, SimpleRule(F_2014 + [ItemFilter(u".*[kK]urssikönttä.*")])),
                   SimpleRule(F_2014)]),

        FlightRule(lambda ev: 2, ACCT_LASKUTUSLISA, F_KAIKKI_KONEET + F_2014 + F_LASKUTUSLISA, u"Laskutuslisä, %(aircraft)s, %(invoicing_comment)s"),
    ]

    rules_2015 = [
        FlightRule(171, ACCT_DDS, F_DDS + F_2015),
        # Variable price for TOW in the second period, based on purpose of flight
        FirstRule([FlightRule(124, ACCT_TOWING, F_TOW + F_2015 + [TransferTowFilter()], u"Siirtohinaus, %(duration)d min"),
                   FlightRule(104, ACCT_TOW, F_TOW + F_2015)
               ]),

        pursi_rule_2015(F_2015 + F_FK, 15),
        pursi_rule_2015(F_2015 + F_FM, 25, 10),
        pursi_rule_2015(F_2015 + F_FQ, 25),
        pursi_rule_2015(F_2015 + F_FY, 32, 32, 10),
        pursi_rule_2015(F_2015 + F_DG, 40, 10, 10),
        pursi_rule_2015(F_2015 + F_TK, 25, 10, 0),

        # Koululentomaksu
        FlightRule(lambda ev: 5, ACCT_PURSI_INSTRUCTION, F_PURTSIKKA + F_2015 + [PurposeFilter("KOU")], "Koululentomaksu, %(aircraft)s"),

        CappedRule(ID_KM_2015, 90, ctx,
                   AllRules([CappedRule(ID_KM_P_2015, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2015 + F_PURTSIKKA_2015,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min")),
                              CappedRule(ID_KM_M_2015, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2015 + F_MOTTI,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min"))])),

        # Normal simple events
        FirstRule([SetDateRule(ID_PK_2015, ctx, SimpleRule(F_2015 + [ItemFilter(u".*[pP]ursikönttä.*")])),
                   SetDateRule(ID_KK_2015, ctx, SimpleRule(F_2015 + [ItemFilter(u".*[kK]urssikönttä.*")])),
                   SimpleRule(F_2015)]),

        FlightRule(lambda ev: 2, ACCT_LASKUTUSLISA, F_KAIKKI_KONEET + F_2015 + F_LASKUTUSLISA, u"Laskutuslisä, %(aircraft)s, %(invoicing_comment)s")
    ]

    rules_2016 = [
        FlightRule(171, ACCT_DDS, F_DDS + F_2016),
        # Variable price for TOW in the second period, based on purpose of flight
        FirstRule([FlightRule(124, ACCT_TOWING, F_TOW + F_2016 + [TransferTowFilter()], u"Siirtohinaus, %(duration)d min"),
                   FlightRule(104, ACCT_TOW, F_TOW + F_2016)
               ]),

        pursi_rule_2016(F_2016 + F_FK, 15),
        pursi_rule_2016(F_2016 + F_FM, 25, 10),
        pursi_rule_2016(F_2016 + F_FQ, 25),
        pursi_rule_2016(F_2016 + F_FY, 32, 32, 10),
        pursi_rule_2016(F_2016 + F_DG, 40, 10, 10),
        pursi_rule_2016(F_2016 + F_HB, 25, 10, 0),

        # Koululentomaksu
        FlightRule(lambda ev: 5, ACCT_PURSI_INSTRUCTION, F_PURTSIKKA_2016 + F_2016 + [PurposeFilter("KOU")], "Koululentomaksu, %(aircraft)s"),

        CappedRule(ID_KM_2016, 90, ctx,
                   AllRules([CappedRule(ID_KM_P_2016, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2016 + F_PURTSIKKA_2016,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min")),
                              CappedRule(ID_KM_M_2016, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2016 + F_MOTTI,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min"))])),

        # Normal simple events
        FirstRule([SetDateRule(ID_PK_2016, ctx, SimpleRule(F_2016 + [ItemFilter(u".*[pP]ursikönttä.*")])),
                   SetDateRule(ID_KK_2016, ctx, SimpleRule(F_2016 + [ItemFilter(u".*[kK]urssikönttä.*")])),
                   SimpleRule(F_2016)]),

        FlightRule(lambda ev: 2, ACCT_LASKUTUSLISA, F_KAIKKI_KONEET + F_2016 + F_LASKUTUSLISA, u"Laskutuslisä, %(aircraft)s, %(invoicing_comment)s")
    ]

    rules_2017 = [
        FlightRule(171, ACCT_DDS, F_DDS + F_2017),
        # Variable price for TOW in the second period, based on purpose of flight
        FirstRule([FlightRule(124, ACCT_TOWING, F_TOW + F_2017 + [TransferTowFilter()], u"Siirtohinaus, %(duration)d min"),
                   FlightRule(104, ACCT_TOW, F_TOW + F_2017)
               ]),

        pursi_rule_2017(F_2017 + F_FK, 15),
        pursi_rule_2017(F_2017 + F_FM, 25, 10),
        pursi_rule_2017(F_2017 + F_FQ, 25),
        pursi_rule_2017(F_2017 + F_FY, 32, 32, 10),
        pursi_rule_2017(F_2017 + F_DG, 40, 10, 10),

        # Koululentomaksu
        FlightRule(lambda ev: 5, ACCT_PURSI_INSTRUCTION, F_PURTSIKKA_2017 + F_2017 + [PurposeFilter("KOU")], "Koululentomaksu, %(aircraft)s"),

        CappedRule(ID_KM_2017, 90, ctx,
                   AllRules([CappedRule(ID_KM_P_2017, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2017 + F_PURTSIKKA_2017,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min")),
                              CappedRule(ID_KM_M_2017, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2017 + F_MOTTI,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min"))])),

        # Normal simple events
        FirstRule([SetDateRule(ID_PK_2017, ctx, SimpleRule(F_2017 + [ItemFilter(u".*[pP]ursikönttä.*")])),
                   SetDateRule(ID_KK_2017, ctx, SimpleRule(F_2017 + [ItemFilter(u".*[kK]urssikönttä.*")])),
                   SimpleRule(F_2017)]),

        FlightRule(lambda ev: 2, ACCT_LASKUTUSLISA, F_KAIKKI_KONEET + F_2017 + F_LASKUTUSLISA, u"Laskutuslisä, %(aircraft)s, %(invoicing_comment)s")
    ]
    
    # Added 2018-11-07:
    rules_2018 = [
        FlightRule(171, ACCT_DDS, F_DDS + F_2018),
        # Variable price for TOW in the second period, based on purpose of flight
        FirstRule([FlightRule(129, ACCT_TOWING, F_TOW + F_2018 + [TransferTowFilter()], u"Siirtohinaus, %(duration)d min"),
                   FlightRule(129, ACCT_TOW, F_TOW + F_2018)
               ]),

        pursi_rule_2018(F_2018 + F_FK, 15),
        pursi_rule_2018(F_2018 + F_FM, 25, 10),
        pursi_rule_2018(F_2018 + F_FQ, 25),
        pursi_rule_2018(F_2018 + F_FY, 32, 32, 10),
        pursi_rule_2018(F_2018 + F_DG, 40, 10, 10),

        # Koululentomaksu
        FlightRule(lambda ev: 5, ACCT_PURSI_INSTRUCTION, F_PURTSIKKA_2018 + F_2018 + [PurposeFilter("KOU")], "Koululentomaksu, %(aircraft)s"),

        CappedRule(ID_KM_2018, 90, ctx,
                   AllRules([CappedRule(ID_KM_P_2018, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2018 + F_PURTSIKKA_2018,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min")),
                              CappedRule(ID_KM_M_2018, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2018 + F_MOTTI,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min"))])),

        # Normal simple events
        FirstRule([SetDateRule(ID_PK_2018, ctx, SimpleRule(F_2018 + [ItemFilter(u".*[pP]ursikönttä.*")])),
                   SetDateRule(ID_KK_2018, ctx, SimpleRule(F_2018 + [ItemFilter(u".*[kK]urssikönttä.*")])),
                   SimpleRule(F_2018)]),

        FlightRule(lambda ev: 2, ACCT_LASKUTUSLISA, F_KAIKKI_KONEET + F_2018 + F_LASKUTUSLISA, u"Laskutuslisä, %(aircraft)s, %(invoicing_comment)s")
    ]
    
    # Added 2019-10-08:
    rules_2019 = [
        FlightRule(171, ACCT_DDS, F_DDS + F_2019),
        # Variable price for TOW in the second period, based on purpose of flight
        FirstRule([FlightRule(129, ACCT_TOWING, F_TOW + F_2019), # + [TransferTowFilter()], u"Siirtohinaus, %(duration)d min"
                   FlightRule(129, ACCT_TOW, F_TOW + F_2019)
               ]),

        pursi_rule_2019(F_2019 + F_FK, 15),
        pursi_rule_2019(F_2019 + F_FM, 25, 10),
        pursi_rule_2019(F_2019 + F_FQ, 25),
        pursi_rule_2019(F_2019 + F_FY, 32, 32, 10),
        pursi_rule_2019(F_2019 + F_FI, 28, 28),
        pursi_rule_2019(F_2019 + F_DG, 40, 10, 10),

        # Koululentomaksu
        FlightRule(lambda ev: 5, ACCT_PURSI_INSTRUCTION, F_PURTSIKKA_2019 + F_2019 + [PurposeFilter("KOU")], "Koululentomaksu, %(aircraft)s"),

        CappedRule(ID_KM_2019, 90, ctx,
                   AllRules([CappedRule(ID_KM_P_2019, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2019 + F_PURTSIKKA_2019,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min")),
                              CappedRule(ID_KM_M_2019, 70, ctx,
                                         FlightRule(10, ACCT_KALUSTO, F_2019 + F_MOTTI,
                                                         u"Kalustomaksu, %(aircraft)s, %(duration)d min"))])),

        # Normal simple events
        FirstRule([SetDateRule(ID_PK_2019, ctx, SimpleRule(F_2019 + [ItemFilter(u".*[pP]ursikönttä.*")])),
                   SetDateRule(ID_KK_2019, ctx, SimpleRule(F_2019 + [ItemFilter(u".*[kK]urssikönttä.*")])),
                   SimpleRule(F_2019)]),

        FlightRule(lambda ev: 2, ACCT_LASKUTUSLISA, F_KAIKKI_KONEET + F_2019 + F_LASKUTUSLISA, u"Laskutuslisä, %(aircraft)s, %(invoicing_comment)s")
    ]
    
    return rules_past + [SetLedgerYearRule(AllRules(rules_2014), 2014),
                         SetLedgerYearRule(AllRules(rules_2015), 2015),
                         SetLedgerYearRule(AllRules(rules_2016), 2016),
                         SetLedgerYearRule(AllRules(rules_2017), 2017),
                         SetLedgerYearRule(AllRules(rules_2018), 2018),
                         SetLedgerYearRule(AllRules(rules_2019), 2019)]
コード例 #3
0

def pursi_rule(base_filters, price, kurssi_price=0):
    return FirstRule([
        FlightRule(0, base_filters + F_PURSIK,
                   u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
        FlightRule(
            kurssi_price, base_filters + F_KURSSIK,
            u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"
        ),
        FlightRule(price, base_filters)
    ])


rules = [
    FlightRule(171, F_DDS + F_2014),
    FlightRule(134, F_CAO + F_2014),
    FlightRule(
        146, F_TOW +
        [PeriodFilter(Period(dt.date(2014, 1, 1), dt.date(2014, 3, 31)))]),
    # Variable price for TOW in the second period, based on purpose of flight
    FirstRule([
        FlightRule(
            124, F_TOW + [
                PeriodFilter(Period(dt.date(2013, 4, 1), dt.date(2014, 12,
                                                                 31))),
                TransferTowFilter()
            ], u"Siirtohinaus, %(duration)d min"),
        FlightRule(
            104, F_TOW +
            [PeriodFilter(Period(dt.date(2013, 4, 1), dt.date(2014, 12, 31)))])
コード例 #4
0
 def pursi_rule_2019(base_filters, price, kurssi_price = 0, package_price = 0):
     return FirstRule([FlightRule(package_price, ACCT_PURSI_KEIKKA, base_filters + F_PURSIK_2019, u"Lento, pursiköntällä, %(aircraft)s, %(duration)d min"),
                       FlightRule(kurssi_price, ACCT_PURSI_KEIKKA, base_filters + F_KURSSIK_2019, u"Lento, kurssiköntällä, %(aircraft)s, %(duration)d min, %(purpose)s"),
                       FlightRule(price, ACCT_PURSI_KEIKKA, base_filters)])