<?php

namespace App\Swagger\v1;

/**
 * @OA\Tag(name="Purchases", description="매입 관리")
 *
 * @OA\Schema(
 *     schema="Purchase",
 *     type="object",
 *     description="매입 정보",
 *
 *     @OA\Property(property="id", type="integer", example=1, description="매입 ID"),
 *     @OA\Property(property="tenant_id", type="integer", example=1, description="테넌트 ID"),
 *     @OA\Property(property="purchase_number", type="string", example="PU202501150001", description="매입번호"),
 *     @OA\Property(property="purchase_date", type="string", format="date", example="2025-01-15", description="매입일"),
 *     @OA\Property(property="client_id", type="integer", example=1, description="거래처 ID"),
 *     @OA\Property(property="supply_amount", type="number", format="float", example=1000000, description="공급가액"),
 *     @OA\Property(property="tax_amount", type="number", format="float", example=100000, description="세액"),
 *     @OA\Property(property="total_amount", type="number", format="float", example=1100000, description="합계"),
 *     @OA\Property(property="description", type="string", example="1월 매입", nullable=true, description="적요"),
 *     @OA\Property(property="status", type="string", enum={"draft","confirmed"}, example="draft", description="상태"),
 *     @OA\Property(property="withdrawal_id", type="integer", example=1, nullable=true, description="출금 연결 ID"),
 *     @OA\Property(property="approval_id", type="integer", example=1, nullable=true, description="연결된 품의서/지출결의서 ID"),
 *     @OA\Property(property="client", type="object", nullable=true,
 *         @OA\Property(property="id", type="integer", example=1),
 *         @OA\Property(property="name", type="string", example="(주)공급사"),
 *         description="거래처 정보"
 *     ),
 *     @OA\Property(property="approval", type="object", nullable=true, description="연결된 품의서/지출결의서 정보",
 *         @OA\Property(property="id", type="integer", example=1),
 *         @OA\Property(property="document_number", type="string", example="AP202501150001"),
 *         @OA\Property(property="title", type="string", example="원자재 구매 품의"),
 *         @OA\Property(property="form", type="object", nullable=true,
 *             @OA\Property(property="id", type="integer", example=1),
 *             @OA\Property(property="name", type="string", example="품의서"),
 *             @OA\Property(property="category", type="string", example="proposal")
 *         )
 *     ),
 *     @OA\Property(property="created_by", type="integer", example=1, nullable=true, description="생성자 ID"),
 *     @OA\Property(property="created_at", type="string", format="date-time"),
 *     @OA\Property(property="updated_at", type="string", format="date-time")
 * )
 *
 * @OA\Schema(
 *     schema="PurchaseCreateRequest",
 *     type="object",
 *     required={"purchase_date","client_id","supply_amount","tax_amount","total_amount"},
 *     description="매입 등록 요청",
 *
 *     @OA\Property(property="purchase_date", type="string", format="date", example="2025-01-15", description="매입일"),
 *     @OA\Property(property="client_id", type="integer", example=1, description="거래처 ID"),
 *     @OA\Property(property="supply_amount", type="number", format="float", example=1000000, description="공급가액"),
 *     @OA\Property(property="tax_amount", type="number", format="float", example=100000, description="세액"),
 *     @OA\Property(property="total_amount", type="number", format="float", example=1100000, description="합계"),
 *     @OA\Property(property="description", type="string", example="1월 매입", maxLength=1000, nullable=true, description="적요"),
 *     @OA\Property(property="withdrawal_id", type="integer", example=1, nullable=true, description="출금 연결 ID"),
 *     @OA\Property(property="approval_id", type="integer", example=1, nullable=true, description="연결할 품의서/지출결의서 ID")
 * )
 *
 * @OA\Schema(
 *     schema="PurchaseUpdateRequest",
 *     type="object",
 *     description="매입 수정 요청",
 *
 *     @OA\Property(property="purchase_date", type="string", format="date", example="2025-01-15", description="매입일"),
 *     @OA\Property(property="client_id", type="integer", example=1, description="거래처 ID"),
 *     @OA\Property(property="supply_amount", type="number", format="float", example=1000000, description="공급가액"),
 *     @OA\Property(property="tax_amount", type="number", format="float", example=100000, description="세액"),
 *     @OA\Property(property="total_amount", type="number", format="float", example=1100000, description="합계"),
 *     @OA\Property(property="description", type="string", example="1월 매입", maxLength=1000, nullable=true, description="적요"),
 *     @OA\Property(property="withdrawal_id", type="integer", example=1, nullable=true, description="출금 연결 ID"),
 *     @OA\Property(property="approval_id", type="integer", example=1, nullable=true, description="연결할 품의서/지출결의서 ID")
 * )
 *
 * @OA\Schema(
 *     schema="PurchaseSummary",
 *     type="object",
 *     description="매입 요약",
 *
 *     @OA\Property(property="total_supply_amount", type="number", format="float", example=10000000, description="총 공급가액"),
 *     @OA\Property(property="total_tax_amount", type="number", format="float", example=1000000, description="총 세액"),
 *     @OA\Property(property="total_amount", type="number", format="float", example=11000000, description="총 합계"),
 *     @OA\Property(property="total_count", type="integer", example=10, description="총 건수"),
 *     @OA\Property(property="by_status", type="object", description="상태별 합계",
 *         @OA\Property(property="draft", type="object",
 *             @OA\Property(property="total", type="number", example=5500000),
 *             @OA\Property(property="count", type="integer", example=5)
 *         ),
 *         @OA\Property(property="confirmed", type="object",
 *             @OA\Property(property="total", type="number", example=5500000),
 *             @OA\Property(property="count", type="integer", example=5)
 *         )
 *     )
 * )
 *
 * @OA\Schema(
 *     schema="PurchaseDashboardDetail",
 *     type="object",
 *     description="매입 대시보드 상세 (CEO 대시보드 모달용)",
 *
 *     @OA\Property(property="summary", type="object", description="요약 정보",
 *         @OA\Property(property="current_month_total", type="number", format="float", example=305000000, description="당월 매입 합계"),
 *         @OA\Property(property="previous_month_total", type="number", format="float", example=276000000, description="전월 매입 합계"),
 *         @OA\Property(property="change_rate", type="number", format="float", example=10.5, description="전월 대비 변화율 (%)"),
 *         @OA\Property(property="count", type="integer", example=45, description="당월 매입 건수")
 *     ),
 *     @OA\Property(property="monthly_trend", type="array", description="월별 추이 (최근 7개월)",
 *
 *         @OA\Items(type="object",
 *
 *             @OA\Property(property="month", type="string", example="2026-01", description="월"),
 *             @OA\Property(property="amount", type="number", format="float", example=280000000, description="매입 합계")
 *         )
 *     ),
 *     @OA\Property(property="by_type", type="array", description="유형별 분포",
 *
 *         @OA\Items(type="object",
 *
 *             @OA\Property(property="type", type="string", example="raw_material", description="유형 코드"),
 *             @OA\Property(property="label", type="string", example="원재료매입", description="유형 라벨"),
 *             @OA\Property(property="amount", type="number", format="float", example=180000000, description="합계"),
 *             @OA\Property(property="ratio", type="number", format="float", example=59.0, description="비율 (%)")
 *         )
 *     ),
 *     @OA\Property(property="items", type="array", description="일별 매입 내역",
 *
 *         @OA\Items(type="object",
 *
 *             @OA\Property(property="id", type="integer", example=1, description="매입 ID"),
 *             @OA\Property(property="date", type="string", format="date", example="2026-01-15", description="매입일"),
 *             @OA\Property(property="vendor_name", type="string", example="대한철강", description="거래처명"),
 *             @OA\Property(property="amount", type="number", format="float", example=15000000, description="매입금액"),
 *             @OA\Property(property="type", type="string", example="raw_material", description="매입유형 코드"),
 *             @OA\Property(property="type_label", type="string", example="원재료매입", description="매입유형 라벨")
 *         )
 *     )
 * )
 */
class PurchaseApi
{
    /**
     * @OA\Get(
     *     path="/api/v1/purchases",
     *     tags={"Purchases"},
     *     summary="매입 목록 조회",
     *     description="매입 목록을 조회합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Parameter(name="search", in="query", description="검색어 (매입번호, 거래처명, 적요)", @OA\Schema(type="string")),
     *     @OA\Parameter(name="start_date", in="query", description="시작일", @OA\Schema(type="string", format="date")),
     *     @OA\Parameter(name="end_date", in="query", description="종료일", @OA\Schema(type="string", format="date")),
     *     @OA\Parameter(name="client_id", in="query", description="거래처 ID", @OA\Schema(type="integer")),
     *     @OA\Parameter(name="status", in="query", description="상태", @OA\Schema(type="string", enum={"draft","confirmed"})),
     *     @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"purchase_date","total_amount","created_at"}, default="purchase_date")),
     *     @OA\Parameter(name="sort_dir", in="query", description="정렬 방향", @OA\Schema(type="string", enum={"asc","desc"}, default="desc")),
     *     @OA\Parameter(ref="#/components/parameters/Page"),
     *     @OA\Parameter(ref="#/components/parameters/Size"),
     *
     *     @OA\Response(
     *         response=200,
     *         description="조회 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(
     *                         property="data",
     *                         type="object",
     *                         @OA\Property(property="current_page", type="integer", example=1),
     *                         @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/Purchase")),
     *                         @OA\Property(property="per_page", type="integer", example=20),
     *                         @OA\Property(property="total", type="integer", example=50)
     *                     )
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function index() {}

    /**
     * @OA\Post(
     *     path="/api/v1/purchases",
     *     tags={"Purchases"},
     *     summary="매입 등록",
     *     description="새로운 매입을 등록합니다. 매입번호는 자동 생성됩니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\RequestBody(
     *         required=true,
     *
     *         @OA\JsonContent(ref="#/components/schemas/PurchaseCreateRequest")
     *     ),
     *
     *     @OA\Response(
     *         response=201,
     *         description="등록 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", ref="#/components/schemas/Purchase")
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function store() {}

    /**
     * @OA\Get(
     *     path="/api/v1/purchases/summary",
     *     tags={"Purchases"},
     *     summary="매입 요약 조회",
     *     description="기간별 매입 요약을 조회합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Parameter(name="start_date", in="query", description="시작일", @OA\Schema(type="string", format="date")),
     *     @OA\Parameter(name="end_date", in="query", description="종료일", @OA\Schema(type="string", format="date")),
     *     @OA\Parameter(name="client_id", in="query", description="거래처 ID", @OA\Schema(type="integer")),
     *     @OA\Parameter(name="status", in="query", description="상태", @OA\Schema(type="string", enum={"draft","confirmed"})),
     *
     *     @OA\Response(
     *         response=200,
     *         description="조회 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", ref="#/components/schemas/PurchaseSummary")
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function summary() {}

    /**
     * @OA\Get(
     *     path="/api/v1/purchases/dashboard-detail",
     *     tags={"Purchases"},
     *     summary="매입 대시보드 상세 조회",
     *     description="CEO 대시보드 모달용 매입 상세 데이터를 조회합니다. 당월 요약, 월별 추이, 유형별 분포, 일별 내역을 반환합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Response(
     *         response=200,
     *         description="조회 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", ref="#/components/schemas/PurchaseDashboardDetail")
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function dashboardDetail() {}

    /**
     * @OA\Get(
     *     path="/api/v1/purchases/{id}",
     *     tags={"Purchases"},
     *     summary="매입 상세 조회",
     *     description="매입 상세 정보를 조회합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Parameter(name="id", in="path", required=true, description="매입 ID", @OA\Schema(type="integer")),
     *
     *     @OA\Response(
     *         response=200,
     *         description="조회 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", ref="#/components/schemas/Purchase")
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=404, description="매입 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function show() {}

    /**
     * @OA\Put(
     *     path="/api/v1/purchases/{id}",
     *     tags={"Purchases"},
     *     summary="매입 수정",
     *     description="매입 정보를 수정합니다. 임시저장(draft) 상태에서만 수정 가능합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Parameter(name="id", in="path", required=true, description="매입 ID", @OA\Schema(type="integer")),
     *
     *     @OA\RequestBody(
     *         required=true,
     *
     *         @OA\JsonContent(ref="#/components/schemas/PurchaseUpdateRequest")
     *     ),
     *
     *     @OA\Response(
     *         response=200,
     *         description="수정 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", ref="#/components/schemas/Purchase")
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=400, description="잘못된 요청 또는 수정 불가", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=404, description="매입 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function update() {}

    /**
     * @OA\Delete(
     *     path="/api/v1/purchases/{id}",
     *     tags={"Purchases"},
     *     summary="매입 삭제",
     *     description="매입을 삭제합니다. 임시저장(draft) 상태에서만 삭제 가능합니다. (Soft Delete)",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Parameter(name="id", in="path", required=true, description="매입 ID", @OA\Schema(type="integer")),
     *
     *     @OA\Response(
     *         response=200,
     *         description="삭제 성공",
     *
     *         @OA\JsonContent(ref="#/components/schemas/ApiResponse")
     *     ),
     *
     *     @OA\Response(response=400, description="삭제 불가", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=404, description="매입 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function destroy() {}

    /**
     * @OA\Post(
     *     path="/api/v1/purchases/{id}/confirm",
     *     tags={"Purchases"},
     *     summary="매입 확정",
     *     description="매입을 확정합니다. 임시저장(draft) 상태에서만 확정 가능합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\Parameter(name="id", in="path", required=true, description="매입 ID", @OA\Schema(type="integer")),
     *
     *     @OA\Response(
     *         response=200,
     *         description="확정 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", ref="#/components/schemas/Purchase")
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=400, description="확정 불가", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=404, description="매입 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function confirm() {}

    /**
     * @OA\Post(
     *     path="/api/v1/purchases/bulk-update-type",
     *     tags={"Purchases"},
     *     summary="매입유형 일괄 변경",
     *     description="선택한 매입 건들의 매입유형을 일괄 변경합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\RequestBody(
     *         required=true,
     *
     *         @OA\JsonContent(
     *             required={"ids","purchase_type"},
     *
     *             @OA\Property(property="ids", type="array", description="매입 ID 목록", @OA\Items(type="integer"), example={1,2,3}),
     *             @OA\Property(property="purchase_type", type="string", description="매입유형", enum={"unset","raw_material","subsidiary_material","product","outsourcing","consumables","repair","transportation","office_supplies","rent","utilities","communication","vehicle","entertainment","insurance","other_service"}, example="raw_material")
     *         )
     *     ),
     *
     *     @OA\Response(
     *         response=200,
     *         description="변경 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", type="object",
     *                         @OA\Property(property="updated_count", type="integer", example=3, description="변경된 건수")
     *                     )
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function bulkUpdatePurchaseType() {}

    /**
     * @OA\Post(
     *     path="/api/v1/purchases/bulk-update-tax-received",
     *     tags={"Purchases"},
     *     summary="세금계산서 수취 일괄 설정",
     *     description="선택한 매입 건들의 세금계산서 수취 여부를 일괄 설정합니다.",
     *     security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
     *
     *     @OA\RequestBody(
     *         required=true,
     *
     *         @OA\JsonContent(
     *             required={"ids","tax_invoice_received"},
     *
     *             @OA\Property(property="ids", type="array", description="매입 ID 목록", @OA\Items(type="integer"), example={1,2,3}),
     *             @OA\Property(property="tax_invoice_received", type="boolean", description="세금계산서 수취 여부", example=true)
     *         )
     *     ),
     *
     *     @OA\Response(
     *         response=200,
     *         description="설정 성공",
     *
     *         @OA\JsonContent(
     *             allOf={
     *
     *                 @OA\Schema(ref="#/components/schemas/ApiResponse"),
     *                 @OA\Schema(
     *
     *                     @OA\Property(property="data", type="object",
     *                         @OA\Property(property="updated_count", type="integer", example=3, description="변경된 건수")
     *                     )
     *                 )
     *             }
     *         )
     *     ),
     *
     *     @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
     *     @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
     * )
     */
    public function bulkUpdateTaxReceived() {}
}
