Files
sam-api/app/Swagger/v1/PurchaseApi.php
hskwon 7282c1ee07 feat: 매입 일괄 업데이트 API 추가
- 매입유형 일괄 변경 API (POST /purchases/bulk-update-type)
- 세금계산서 수취 일괄 설정 API (POST /purchases/bulk-update-tax-received)
- FormRequest 검증 클래스 추가
- Swagger 문서 추가
2026-01-19 19:42:05 +09:00

425 lines
20 KiB
PHP

<?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="client", type="object", nullable=true,
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="(주)공급사"),
* description="거래처 정보"
* ),
* @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\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\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)
* )
* )
* )
*/
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/{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() {}
}