# -*- coding: utf-8 -*-
from sysactions import (
    action,
    show_info_message,
    get_model,
    get_custom,
    show_messagebox,
)

from actions.util.get_menu_user_logged import get_menu_manager_authenticated_user
from msgbusboundary import (
    Rupture,
)


@action
def do_sync_delivery_menu(
    pos_id,     # type: str
):
    # type: (...) -> None

    model = get_model(pos_id)
    user_id = get_custom(model, 'Last Manager ID') or get_menu_manager_authenticated_user(int(pos_id))

    current_disabled = Rupture.get_disabled_products()
    Rupture.update_items(
        user_id=user_id,
        parts_to_enable=[],
        parts_to_disable=current_disabled,
    )
    show_messagebox(pos_id, "$DELIVERY_SYNC_STARTED")
