<?php

declare(strict_types=1);

/**
 * 本文件属于 DBErp 进销存系统。
 *
 * 版权所有 © 2026 北京珑大钜商科技有限公司。保留所有权利。
 *
 * 未经官方授权，不得删除、篡改或隐藏本文件中的版权声明、产品标识与来源信息。
 * 商业授权、官方更新与技术支持服务，请以珑大官方支持中心记录为准。
 *
 * @link https://support.loongdom.cn
 * @see  https://www.dberp.com.cn
 */

namespace App\Services;

/**
 * 菜单级权限（NAV_*）与升级前「旧入口条件」的对应关系，供迁移与双轨鉴权共用。
 */
final class DberpNavigationPermissionDefinition
{
    /**
     * @return array<string, list<string>> nav_code => legacy permission codes（任一则视为曾能进该菜单）
     */
    public static function navCodeToLegacyPermissionCodes(): array
    {
        return [
            DberpPermissionService::NAV_SALES_ANALYSIS => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PURCHASE_ANALYSIS => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_INVENTORY_ANALYSIS => [
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_INVENTORY_EXCEPTION,
                DberpPermissionService::VIEW_STOCKTAKE_DIFFERENCE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SETTLEMENT_ANALYSIS => [
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_COMPREHENSIVE_SUMMARY_ANALYSIS => [
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_INVENTORY_ALERT,
            ],
            DberpPermissionService::NAV_INVENTORY_SUMMARY => [
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_INVENTORY_EXCEPTION,
                DberpPermissionService::VIEW_STOCKTAKE_DIFFERENCE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SETTLEMENT_AGING_ANALYSIS => [
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_DOCUMENT_QUERY => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_INVENTORY_TRANSACTION_QUERY => [
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_INVENTORY_EXCEPTION,
                DberpPermissionService::VIEW_STOCKTAKE_DIFFERENCE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SALES_STATISTICS => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_PRICE_RULE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PURCHASE_STATISTICS => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_CUSTOMER_SALES_RANKING => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_PRICE_RULE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_SUPPLIER_PURCHASE_RANKING => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PRODUCT_SALES_RANKING => [
                DberpPermissionService::VIEW_SALES_ORDER,
                DberpPermissionService::VIEW_SALES_OUTBOUND,
                DberpPermissionService::VIEW_SALES_RETURN,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_PRICE_RULE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_CUSTOMER_CREDIT_CONTROL,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PRODUCT_PURCHASE_RANKING => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_PRODUCT_BUSINESS_QUERY => [
                DberpPermissionService::VIEW_PURCHASE_ORDER,
                DberpPermissionService::VIEW_PURCHASE_RECEIPT,
                DberpPermissionService::VIEW_SALES_QUOTE,
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_INVENTORY_ALERT,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
            ],
            DberpPermissionService::NAV_RECEIPT_PAYMENT_QUERY => [
                DberpPermissionService::VIEW_CUSTOMER_RECEIVABLE,
                DberpPermissionService::VIEW_SUPPLIER_PAYABLE,
                DberpPermissionService::VIEW_WORKBENCH_OVERVIEW,
                DberpPermissionService::CREATE_RECEIPT_ORDER,
                DberpPermissionService::CREATE_PAYMENT_ORDER,
                DberpPermissionService::CONFIRM_RECEIPT_PAYMENT,
                DberpPermissionService::WRITE_OFF,
            ],
            DberpPermissionService::NAV_PURCHASE_INQUIRY_COMPARISON => [
                DberpPermissionService::VIEW_PURCHASE_INQUIRY_QUOTE,
                DberpPermissionService::VIEW_PURCHASE_REQUEST,
            ],
        ];
    }
}
