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 등록
This commit is contained in:
92
app/Models/Tenants/Withdrawal.php
Normal file
92
app/Models/Tenants/Withdrawal.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Withdrawal extends Model
|
||||
{
|
||||
use BelongsToTenant, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'withdrawal_date',
|
||||
'client_id',
|
||||
'client_name',
|
||||
'bank_account_id',
|
||||
'amount',
|
||||
'payment_method',
|
||||
'account_code',
|
||||
'description',
|
||||
'reference_type',
|
||||
'reference_id',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'withdrawal_date' => 'date',
|
||||
'amount' => 'decimal:2',
|
||||
'client_id' => 'integer',
|
||||
'bank_account_id' => 'integer',
|
||||
'reference_id' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 결제수단 목록
|
||||
*/
|
||||
public const PAYMENT_METHODS = [
|
||||
'cash' => '현금',
|
||||
'transfer' => '계좌이체',
|
||||
'card' => '카드',
|
||||
'check' => '수표',
|
||||
];
|
||||
|
||||
/**
|
||||
* 거래처 관계
|
||||
*/
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 출금 계좌 관계
|
||||
*/
|
||||
public function bankAccount(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BankAccount::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 생성자 관계
|
||||
*/
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래처명 조회 (회원/비회원 통합)
|
||||
*/
|
||||
public function getDisplayClientNameAttribute(): string
|
||||
{
|
||||
if ($this->client) {
|
||||
return $this->client->name;
|
||||
}
|
||||
|
||||
return $this->client_name ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 결제수단 라벨
|
||||
*/
|
||||
public function getPaymentMethodLabelAttribute(): string
|
||||
{
|
||||
return self::PAYMENT_METHODS[$this->payment_method] ?? $this->payment_method;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user