# Polleo Demand — Role × Section permission matrix.
#
# Single source of truth for "who sees what". Backend reads this on startup
# and exposes per-user allowed sections via /api/auth/me/sections. Frontend
# filters the sidebar by that list.
#
# To add a new role or grant access, edit this file and restart the API.
# Section identifiers MUST match the keys the backend `require_section()`
# dependency uses (registered in backend/services/permissions.py).
#
# Admin gets EVERY section automatically — no need to list them below.

roles:
  - Admin
  - Veleprodaja
  - Maloprodaja
  - Nabava
  - Marketing
  - Uprava

# section_id: [list of roles] — Admin always implicitly included
# Group keys (demand_op / demand_an / supply_op / ...) are for readability,
# the leaf section_id is what the code checks.

permissions:
  home:
    dashboard:            [Admin, Veleprodaja, Maloprodaja, Nabava, Marketing, Uprava]

  executive:
    executive_dashboard:  [Admin, Uprava]

  polleo_ai:
    polleo_ai:            [Admin, Veleprodaja, Maloprodaja, Nabava, Marketing, Uprava]  # read-only NL analytics — safe for all roles

  demand_op:
    upload_sales:         [Admin]
    upload_stock:         [Admin, Nabava]
    upload_incoming:      [Admin, Nabava]   # incoming-PO matrix → incoming_supply
    run_forecast:         [Admin]
    kam_cm_input:         [Admin, Veleprodaja, Nabava]
    demand_planning:      [Admin]

  demand_an:
    input_status:         [Admin]
    sop_meeting:          [Admin, Uprava]
    consensus_plan:       [Admin]
    wholesale_review:     [Admin, Veleprodaja]   # KAM commit-vs-pull control (+ Availability WS share this)
    demand_review:        [Admin, Veleprodaja, Maloprodaja, Nabava]  # consensus forecast sign-off
    sales_weekly:         [Admin, Veleprodaja, Maloprodaja, Nabava, Marketing, Uprava]
    sales_history:        [Admin, Nabava]
    revenue_forecast:     [Admin, Veleprodaja, Maloprodaja, Nabava, Marketing, Uprava]
    forecast_accuracy:    [Admin, Veleprodaja, Maloprodaja, Nabava, Marketing, Uprava]
    watchlist:            [Admin, Nabava]
    sku_list:             [Admin]
    sku_detail:           [Admin]

  supply_op:
    order_entry:          [Admin, Nabava]
    order_proposal:       [Admin, Nabava]  # Order Proposal per Supplier (replaces Order Alerts)
    settings:             [Admin, Nabava]
    logistics_by_supplier: [Admin, Nabava]
    logistics_detail:     [Admin, Nabava]
    logistics_master:     [Admin, Nabava]  # Pallet master + MOQ edit

  supply_an:
    supply_dashboard:     [Admin, Nabava, Uprava]
    inventory_health:     [Admin, Nabava]
    stock_projection:     [Admin, Nabava, Uprava]
    coverage_workbook:    [Admin, Nabava]
    reorder_alerts:       [Admin, Nabava]
    scenario_planner:     [Admin, Nabava]
    store_overstock:      [Admin]
    moq_analysis:         [Admin]
    costs_margins:        [Admin]
    logistics_by_week:    [Admin, Nabava]
    logistics_pallet_flow: [Admin, Nabava]
    logistics_truck_plan: [Admin, Nabava]
    logistics_moq_audit:  [Admin, Nabava]

  promo_op:
    promo_planner:        [Admin, Nabava, Marketing]
    promo_my_proposals:   [Admin, Nabava, Marketing]
    promo_approvals:      [Admin, Nabava, Marketing]

  promo_an:
    promo_overview:       [Admin, Nabava, Marketing]
    promo_calendar:       [Admin, Nabava, Marketing]
    promo_forecaster:     [Admin, Nabava, Marketing]
    promo_past:           [Admin, Nabava, Marketing]
    promo_performance:    [Admin, Nabava, Marketing]
    promo_past_web:       [Admin, Nabava, Marketing]

  npl_op:
    npl_module:           [Admin, Nabava, Veleprodaja]

  npl_an:
    npl_dashboard:        [Admin, Nabava, Veleprodaja]
    npl_report:           [Admin, Nabava, Veleprodaja, Uprava]

  finance:
    finance_dashboard:    [Admin, Nabava, Uprava]
    finance_lost_sales:   [Admin, Nabava, Uprava]
    finance_locked_cash:  [Admin, Nabava, Uprava]
    finance_contest_risk: [Admin, Nabava, Uprava]
    finance_slow_movers:  [Admin, Nabava, Uprava]
    finance_bridge:       [Admin, Uprava]

  admin:
    user_management:      [Admin]
    npl_admin_enum:       [Admin]
    on_top_changes_audit: [Admin]   # KAM/CM on-top change-control feed (per-KAM, move detection)
