
def discount_in_all_items(benefit):
    actions = [str(e[1].items()[0][0]) for e in benefit.get("actions", {}).items()]
    actions_pass = ['discountPercentageOnTotal',
                    'discountAmountOnTotal',
                    'discountPercentageByGroupsOnTotal',
                    'discountAmountByGroupsOnTotal']

    has_item_pass = [item for item in actions if item in actions_pass]
    return len(has_item_pass) > 0


def check_item_in_action(benefit, part_code):
    items = [e[1].items()[0][1] for e in benefit.get("actions", {}).items()]
    items = [str(i[0]["item"]) for i in items]
    return len(items) > 0 and part_code in items
