Files
sam-api/app/Models/Tenants/ExpenseAccount.php
권혁성 c46b950fde feat: 회계 시스템 확장 — 계정과목·전표·세금계산서·카드·바로빌
- 계정과목 확장 및 더존 Smart A 표준 시딩 (전 테넌트)
- 전표 연동 시스템 구현 (JournalSyncService, SyncsExpenseAccounts)
- 세금계산서 매입/매출 필수값 조건 분리 + null 방어
- 카드거래 대시보드 리다이렉트 + 악성채권 집계 수정
- 바로빌 연동 API 엔드포인트 추가
- 복리후생 날짜 필터 + 바로빌 조인 컬럼 수정
- codebridge DB 커넥션 설정 추가
2026-03-10 11:29:39 +09:00

108 lines
2.5 KiB
PHP

<?php
namespace App\Models\Tenants;
use App\Models\Orders\Client;
use App\Traits\Auditable;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* 비용 계정 모델
*
* CEO 대시보드용 비용 데이터 (복리후생비, 접대비 등)
*/
class ExpenseAccount extends Model
{
use Auditable, BelongsToTenant, HasFactory, ModelTrait, SoftDeletes;
protected $table = 'expense_accounts';
protected $fillable = [
'tenant_id',
'account_type',
'sub_type',
'expense_date',
'amount',
'description',
'receipt_no',
'vendor_id',
'vendor_name',
'payment_method',
'card_no',
'loan_id',
'journal_entry_id',
'journal_entry_line_id',
'created_by',
'updated_by',
'deleted_by',
];
protected $casts = [
'expense_date' => 'date',
'amount' => 'decimal:2',
];
// 계정 유형 상수
public const TYPE_WELFARE = 'welfare';
public const TYPE_ENTERTAINMENT = 'entertainment';
public const TYPE_TRAVEL = 'travel';
public const TYPE_OFFICE = 'office';
// 세부 유형 상수 (접대비)
public const SUB_TYPE_GIFT_CERTIFICATE = 'gift_certificate';
// 세부 유형 상수 (복리후생)
public const SUB_TYPE_MEAL = 'meal';
public const SUB_TYPE_HEALTH = 'health';
public const SUB_TYPE_EDUCATION = 'education';
// 결제 수단 상수
public const PAYMENT_CARD = 'card';
public const PAYMENT_CASH = 'cash';
public const PAYMENT_TRANSFER = 'transfer';
/**
* 거래처 관계
*/
public function vendor(): BelongsTo
{
return $this->belongsTo(Client::class, 'vendor_id');
}
/**
* 복리후생비 스코프
*/
public function scopeWelfare($query)
{
return $query->where('account_type', self::TYPE_WELFARE);
}
/**
* 접대비 스코프
*/
public function scopeEntertainment($query)
{
return $query->where('account_type', self::TYPE_ENTERTAINMENT);
}
/**
* 기간 필터 스코프
*/
public function scopeInPeriod($query, string $startDate, string $endDate)
{
return $query->whereBetween('expense_date', [$startDate, $endDate]);
}
}