feat: 매출/매입 관리 API 구현
- 매출(Sale) 및 매입(Purchase) CRUD API 구현
- 문서번호 자동 생성 (SL/PU + YYYYMMDD + 시퀀스)
- 상태 관리 (draft → confirmed → invoiced)
- 확정(confirm) 및 요약(summary) 기능 추가
- BelongsToTenant, SoftDeletes 적용
- Swagger API 문서 작성 완료
추가된 파일:
- 마이그레이션: sales, purchases 테이블
- 모델: Sale, Purchase
- 서비스: SaleService, PurchaseService
- 컨트롤러: SaleController, PurchaseController
- FormRequest: Store/Update 4개
- Swagger: SaleApi.php, PurchaseApi.php
API 엔드포인트 (14개):
- GET/POST /v1/sales, /v1/purchases
- GET/PUT/DELETE /v1/{sales,purchases}/{id}
- POST /v1/{sales,purchases}/{id}/confirm
- GET /v1/{sales,purchases}/summary
This commit is contained in:
48
database/migrations/2025_12_17_100001_create_sales_table.php
Normal file
48
database/migrations/2025_12_17_100001_create_sales_table.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sales', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->string('sale_number', 30)->comment('매출번호');
|
||||
$table->date('sale_date')->comment('매출일자');
|
||||
$table->unsignedBigInteger('client_id')->comment('거래처 ID');
|
||||
$table->decimal('supply_amount', 15, 2)->comment('공급가액');
|
||||
$table->decimal('tax_amount', 15, 2)->comment('세액');
|
||||
$table->decimal('total_amount', 15, 2)->comment('합계');
|
||||
$table->text('description')->nullable()->comment('적요');
|
||||
$table->string('status', 20)->default('draft')->comment('상태: draft/confirmed/invoiced');
|
||||
$table->unsignedBigInteger('tax_invoice_id')->nullable()->comment('세금계산서 ID');
|
||||
$table->unsignedBigInteger('deposit_id')->nullable()->comment('입금 연결 ID');
|
||||
$table->unsignedBigInteger('created_by')->nullable()->comment('생성자');
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
|
||||
// 인덱스
|
||||
$table->unique(['tenant_id', 'sale_number'], 'uk_tenant_sale_number');
|
||||
$table->index(['tenant_id', 'sale_date'], 'idx_tenant_sale_date');
|
||||
$table->index('client_id', 'idx_client');
|
||||
$table->index('status', 'idx_status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sales');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user