/**
 * 採購單相關常數
 */

import type { PurchaseOrderStatus, PaymentMethod, InvoiceType } from "@/types/purchase-order";

// 狀態標籤配置
export const STATUS_CONFIG: Record<
    PurchaseOrderStatus,
    { label: string; variant: "default" | "secondary" | "destructive" | "outline" }
> = {
    draft: { label: "草稿", variant: "outline" },
    pending: { label: "待審核", variant: "outline" },
    processing: { label: "處理中", variant: "outline" },
    shipping: { label: "運送中", variant: "outline" },
    confirming: { label: "待確認", variant: "outline" },
    completed: { label: "已完成", variant: "outline" },
    cancelled: { label: "已取消", variant: "outline" },
};

export const STATUS_OPTIONS = Object.entries(STATUS_CONFIG).map(([value, config]) => ({
    value,
    label: (config as any).label,
}));

// 付款方式選項
export const PAYMENT_METHODS: Record<PaymentMethod, string> = {
    cash: "現金",
    bank_transfer: "銀行轉帳",
    credit_card: "信用卡",
    check: "支票",
};

// 發票類型選項
export const INVOICE_TYPES: Record<InvoiceType, string> = {
    duplicate: "二聯式",
    triplicate: "三聯式",
    electronic: "電子發票",
};

// 退回原因選項
export const REJECTION_REASONS = [
    { value: "預算不足", label: "預算不足" },
    { value: "非必要採購", label: "非必要採購" },
    { value: "數量過多", label: "數量過多" },
    { value: "價格過高", label: "價格過高" },
    { value: "資訊不完整", label: "資訊不完整" },
    { value: "其他", label: "其他" },
];

/**
 * 價格警示閾值（百分比）
 * 當單價比上次採購價高出此百分比時，顯示警示
 */
export const PRICE_ALERT_THRESHOLD = 5;
