package com.erp.purchase.enums;

/**
 * 采购订单状态
 */
public enum PurchaseOrderStatus {
    DRAFT("draft", "草稿"),
    PENDING("pending", "待审批"),
    APPROVED("approved", "已审批"),
    PARTIAL_INBOUND("partial_inbound", "部分入库"),
    ALL_INBOUND("all_inbound", "全部入库"),
    PARTIAL_RETURN("partial_return", "部分退货"),
    COMPLETED("completed", "已完成"),
    CANCELLED("cancelled", "已取消");

    private final String code;
    private final String desc;

    PurchaseOrderStatus(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() { return code; }
    public String getDesc() { return desc; }

    public static PurchaseOrderStatus fromCode(String code) {
        for (PurchaseOrderStatus s : values()) {
            if (s.code.equals(code)) return s;
        }
        throw new IllegalArgumentException("未知状态: " + code);
    }
}
