Files
sam-api/app/Swagger/v1/DepositApi.php
hskwon 17799c47de feat: 2.4 입금/출금 관리 API 구현
- 마이그레이션: deposits, withdrawals 테이블 생성
- 모델: Deposit, Withdrawal (BelongsToTenant, SoftDeletes)
- 서비스: DepositService, WithdrawalService (CRUD + summary)
- 컨트롤러: DepositController, WithdrawalController
- FormRequest: Store/Update 검증 클래스
- Swagger: 입금/출금 API 문서 (12개 엔드포인트)
- 라우트: /v1/deposits, /v1/withdrawals 등록
2025-12-17 21:47:15 +09:00

314 lines
16 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Deposits", description="입금 관리")
*
* @OA\Schema(
* schema="Deposit",
* 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="deposit_date", type="string", format="date", example="2025-01-15", description="입금일"),
* @OA\Property(property="client_id", type="integer", example=1, nullable=true, description="거래처 ID"),
* @OA\Property(property="client_name", type="string", example="홍길동", nullable=true, description="비회원 거래처명"),
* @OA\Property(property="bank_account_id", type="integer", example=1, nullable=true, description="입금 계좌 ID"),
* @OA\Property(property="amount", type="number", format="float", example=1000000, description="금액"),
* @OA\Property(property="payment_method", type="string", enum={"cash","transfer","card","check"}, example="transfer", description="결제수단"),
* @OA\Property(property="account_code", type="string", example="401", nullable=true, description="계정과목"),
* @OA\Property(property="description", type="string", example="1월 매출 입금", nullable=true, description="적요"),
* @OA\Property(property="reference_type", type="string", example="sales", nullable=true, description="참조 유형"),
* @OA\Property(property="reference_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="bank_account", type="object", nullable=true,
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="bank_name", type="string", example="국민은행"),
* @OA\Property(property="account_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="DepositCreateRequest",
* type="object",
* required={"deposit_date","amount","payment_method"},
* description="입금 등록 요청",
*
* @OA\Property(property="deposit_date", type="string", format="date", example="2025-01-15", description="입금일"),
* @OA\Property(property="client_id", type="integer", example=1, nullable=true, description="거래처 ID"),
* @OA\Property(property="client_name", type="string", example="홍길동", maxLength=100, nullable=true, description="비회원 거래처명"),
* @OA\Property(property="bank_account_id", type="integer", example=1, nullable=true, description="입금 계좌 ID"),
* @OA\Property(property="amount", type="number", format="float", example=1000000, description="금액"),
* @OA\Property(property="payment_method", type="string", enum={"cash","transfer","card","check"}, example="transfer", description="결제수단"),
* @OA\Property(property="account_code", type="string", example="401", maxLength=20, nullable=true, description="계정과목"),
* @OA\Property(property="description", type="string", example="1월 매출 입금", maxLength=1000, nullable=true, description="적요"),
* @OA\Property(property="reference_type", type="string", example="sales", maxLength=50, nullable=true, description="참조 유형"),
* @OA\Property(property="reference_id", type="integer", example=1, nullable=true, description="참조 ID")
* )
*
* @OA\Schema(
* schema="DepositUpdateRequest",
* type="object",
* description="입금 수정 요청",
*
* @OA\Property(property="deposit_date", type="string", format="date", example="2025-01-15", description="입금일"),
* @OA\Property(property="client_id", type="integer", example=1, nullable=true, description="거래처 ID"),
* @OA\Property(property="client_name", type="string", example="홍길동", maxLength=100, nullable=true, description="비회원 거래처명"),
* @OA\Property(property="bank_account_id", type="integer", example=1, nullable=true, description="입금 계좌 ID"),
* @OA\Property(property="amount", type="number", format="float", example=1000000, description="금액"),
* @OA\Property(property="payment_method", type="string", enum={"cash","transfer","card","check"}, example="transfer", description="결제수단"),
* @OA\Property(property="account_code", type="string", example="401", maxLength=20, nullable=true, description="계정과목"),
* @OA\Property(property="description", type="string", example="1월 매출 입금", maxLength=1000, nullable=true, description="적요"),
* @OA\Property(property="reference_type", type="string", example="sales", maxLength=50, nullable=true, description="참조 유형"),
* @OA\Property(property="reference_id", type="integer", example=1, nullable=true, description="참조 ID")
* )
*
* @OA\Schema(
* schema="DepositSummary",
* type="object",
* description="입금 요약",
*
* @OA\Property(property="total_amount", type="number", format="float", example=5000000, description="총 입금액"),
* @OA\Property(property="total_count", type="integer", example=10, description="총 건수"),
* @OA\Property(property="by_payment_method", type="object", description="결제수단별 합계",
* @OA\Property(property="cash", type="object",
* @OA\Property(property="total", type="number", example=1000000),
* @OA\Property(property="count", type="integer", example=2)
* ),
* @OA\Property(property="transfer", type="object",
* @OA\Property(property="total", type="number", example=4000000),
* @OA\Property(property="count", type="integer", example=8)
* )
* )
* )
*/
class DepositApi
{
/**
* @OA\Get(
* path="/api/v1/deposits",
* tags={"Deposits"},
* 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="payment_method", in="query", description="결제수단", @OA\Schema(type="string", enum={"cash","transfer","card","check"})),
* @OA\Parameter(name="bank_account_id", in="query", description="계좌 ID", @OA\Schema(type="integer")),
* @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"deposit_date","amount","created_at"}, default="deposit_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/Deposit")),
* @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/deposits",
* tags={"Deposits"},
* summary="입금 등록",
* description="새로운 입금을 등록합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/DepositCreateRequest")
* ),
*
* @OA\Response(
* response=201,
* description="등록 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/Deposit")
* )
* }
* )
* ),
*
* @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/deposits/summary",
* tags={"Deposits"},
* 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="payment_method", in="query", description="결제수단", @OA\Schema(type="string", enum={"cash","transfer","card","check"})),
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/DepositSummary")
* )
* }
* )
* ),
*
* @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/deposits/{id}",
* tags={"Deposits"},
* 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/Deposit")
* )
* }
* )
* ),
*
* @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/deposits/{id}",
* tags={"Deposits"},
* summary="입금 수정",
* description="입금 정보를 수정합니다.",
* 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/DepositUpdateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="수정 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/Deposit")
* )
* }
* )
* ),
*
* @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/deposits/{id}",
* tags={"Deposits"},
* summary="입금 삭제",
* description="입금을 삭제합니다. (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=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() {}
}