feat: [재무] 어음 V8 + 상품권 접대비 연동 + 일반전표/계정과목 API
- Bill 확장 필드 (V8), Loan 상품권 카테고리/접대비 자동 연동 - GeneralJournalEntry CRUD, AccountSubject API - 접대비/복리후생비 날짜 필터, 매출채권 soft delete 제외 - 바로빌 연동 API 엔드포인트 추가 - 부가세 상세 조회 API Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
49
app/Models/Tenants/AccountCode.php
Normal file
49
app/Models/Tenants/AccountCode.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AccountCode extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'code',
|
||||
'name',
|
||||
'category',
|
||||
'sort_order',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'sort_order' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// Categories
|
||||
public const CATEGORY_ASSET = 'asset';
|
||||
public const CATEGORY_LIABILITY = 'liability';
|
||||
public const CATEGORY_CAPITAL = 'capital';
|
||||
public const CATEGORY_REVENUE = 'revenue';
|
||||
public const CATEGORY_EXPENSE = 'expense';
|
||||
|
||||
public const CATEGORIES = [
|
||||
self::CATEGORY_ASSET => '자산',
|
||||
self::CATEGORY_LIABILITY => '부채',
|
||||
self::CATEGORY_CAPITAL => '자본',
|
||||
self::CATEGORY_REVENUE => '수익',
|
||||
self::CATEGORY_EXPENSE => '비용',
|
||||
];
|
||||
|
||||
/**
|
||||
* 활성 계정과목만 조회
|
||||
*/
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,58 @@ class Bill extends Model
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
// V8 확장 필드
|
||||
'instrument_type',
|
||||
'medium',
|
||||
'bill_category',
|
||||
'electronic_bill_no',
|
||||
'registration_org',
|
||||
'drawee',
|
||||
'acceptance_status',
|
||||
'acceptance_date',
|
||||
'acceptance_refusal_date',
|
||||
'acceptance_refusal_reason',
|
||||
'endorsement',
|
||||
'endorsement_order',
|
||||
'storage_place',
|
||||
'issuer_bank',
|
||||
'is_discounted',
|
||||
'discount_date',
|
||||
'discount_bank',
|
||||
'discount_rate',
|
||||
'discount_amount',
|
||||
'endorsement_date',
|
||||
'endorsee',
|
||||
'endorsement_reason',
|
||||
'collection_bank',
|
||||
'collection_request_date',
|
||||
'collection_fee',
|
||||
'collection_complete_date',
|
||||
'collection_result',
|
||||
'collection_deposit_date',
|
||||
'collection_deposit_amount',
|
||||
'settlement_bank',
|
||||
'payment_method',
|
||||
'actual_payment_date',
|
||||
'payment_place',
|
||||
'payment_place_detail',
|
||||
'renewal_date',
|
||||
'renewal_new_bill_no',
|
||||
'renewal_reason',
|
||||
'recourse_date',
|
||||
'recourse_amount',
|
||||
'recourse_target',
|
||||
'recourse_reason',
|
||||
'buyback_date',
|
||||
'buyback_amount',
|
||||
'buyback_bank',
|
||||
'dishonored_date',
|
||||
'dishonored_reason',
|
||||
'has_protest',
|
||||
'protest_date',
|
||||
'recourse_notice_date',
|
||||
'recourse_notice_deadline',
|
||||
'is_split',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -41,21 +93,57 @@ class Bill extends Model
|
||||
'bank_account_id' => 'integer',
|
||||
'installment_count' => 'integer',
|
||||
'is_electronic' => 'boolean',
|
||||
// V8 확장 casts
|
||||
'acceptance_date' => 'date',
|
||||
'acceptance_refusal_date' => 'date',
|
||||
'discount_date' => 'date',
|
||||
'discount_rate' => 'decimal:2',
|
||||
'discount_amount' => 'decimal:2',
|
||||
'endorsement_date' => 'date',
|
||||
'collection_request_date' => 'date',
|
||||
'collection_fee' => 'decimal:2',
|
||||
'collection_complete_date' => 'date',
|
||||
'collection_deposit_date' => 'date',
|
||||
'collection_deposit_amount' => 'decimal:2',
|
||||
'actual_payment_date' => 'date',
|
||||
'renewal_date' => 'date',
|
||||
'recourse_date' => 'date',
|
||||
'recourse_amount' => 'decimal:2',
|
||||
'buyback_date' => 'date',
|
||||
'buyback_amount' => 'decimal:2',
|
||||
'dishonored_date' => 'date',
|
||||
'protest_date' => 'date',
|
||||
'recourse_notice_date' => 'date',
|
||||
'recourse_notice_deadline' => 'date',
|
||||
'is_discounted' => 'boolean',
|
||||
'has_protest' => 'boolean',
|
||||
'is_split' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* 배열/JSON 변환 시 날짜 형식 지정
|
||||
*/
|
||||
/**
|
||||
* 날짜 cast 필드 목록 (toArray에서 Y-m-d 형식 변환용)
|
||||
*/
|
||||
private const DATE_FIELDS = [
|
||||
'issue_date', 'maturity_date',
|
||||
'acceptance_date', 'acceptance_refusal_date',
|
||||
'discount_date', 'endorsement_date',
|
||||
'collection_request_date', 'collection_complete_date', 'collection_deposit_date',
|
||||
'actual_payment_date',
|
||||
'renewal_date', 'recourse_date', 'buyback_date',
|
||||
'dishonored_date', 'protest_date', 'recourse_notice_date', 'recourse_notice_deadline',
|
||||
];
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$array = parent::toArray();
|
||||
|
||||
// 날짜 필드를 Y-m-d 형식으로 변환
|
||||
if (isset($array['issue_date']) && $this->issue_date) {
|
||||
$array['issue_date'] = $this->issue_date->format('Y-m-d');
|
||||
}
|
||||
if (isset($array['maturity_date']) && $this->maturity_date) {
|
||||
$array['maturity_date'] = $this->maturity_date->format('Y-m-d');
|
||||
foreach (self::DATE_FIELDS as $field) {
|
||||
if (isset($array[$field]) && $this->{$field}) {
|
||||
$array[$field] = $this->{$field}->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
@@ -69,14 +157,42 @@ public function toArray(): array
|
||||
'issued' => '발행',
|
||||
];
|
||||
|
||||
/**
|
||||
* 증권종류
|
||||
*/
|
||||
public const INSTRUMENT_TYPES = [
|
||||
'promissory' => '약속어음',
|
||||
'exchange' => '환어음',
|
||||
'cashierCheck' => '자기앞수표',
|
||||
'currentCheck' => '당좌수표',
|
||||
];
|
||||
|
||||
/**
|
||||
* 수취 어음 상태 목록
|
||||
*/
|
||||
public const RECEIVED_STATUSES = [
|
||||
'stored' => '보관중',
|
||||
'endorsed' => '배서양도',
|
||||
'discounted' => '할인',
|
||||
'collectionRequest' => '추심의뢰',
|
||||
'collectionComplete' => '추심완료',
|
||||
'maturityDeposit' => '만기입금',
|
||||
'paymentComplete' => '결제완료',
|
||||
'dishonored' => '부도',
|
||||
'renewed' => '개서',
|
||||
'buyback' => '환매',
|
||||
// 하위호환
|
||||
'maturityAlert' => '만기입금(7일전)',
|
||||
'maturityResult' => '만기결과',
|
||||
'paymentComplete' => '결제완료',
|
||||
];
|
||||
|
||||
/**
|
||||
* 수취 수표 상태 목록
|
||||
*/
|
||||
public const RECEIVED_CHECK_STATUSES = [
|
||||
'stored' => '보관중',
|
||||
'endorsed' => '배서양도',
|
||||
'deposited' => '입금',
|
||||
'dishonored' => '부도',
|
||||
];
|
||||
|
||||
@@ -85,10 +201,25 @@ public function toArray(): array
|
||||
*/
|
||||
public const ISSUED_STATUSES = [
|
||||
'stored' => '보관중',
|
||||
'issued' => '지급대기',
|
||||
'maturityPayment' => '만기결제',
|
||||
'paymentComplete' => '결제완료',
|
||||
'dishonored' => '부도',
|
||||
'renewed' => '개서',
|
||||
// 하위호환
|
||||
'maturityAlert' => '만기입금(7일전)',
|
||||
'collectionRequest' => '추심의뢰',
|
||||
'collectionComplete' => '추심완료',
|
||||
'suing' => '추소중',
|
||||
];
|
||||
|
||||
/**
|
||||
* 발행 수표 상태 목록
|
||||
*/
|
||||
public const ISSUED_CHECK_STATUSES = [
|
||||
'stored' => '보관중',
|
||||
'issued' => '지급대기',
|
||||
'cashed' => '현금화',
|
||||
'dishonored' => '부도',
|
||||
];
|
||||
|
||||
@@ -149,11 +280,25 @@ public function getBillTypeLabelAttribute(): string
|
||||
*/
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
$isCheck = in_array($this->instrument_type, ['cashierCheck', 'currentCheck']);
|
||||
|
||||
if ($this->bill_type === 'received') {
|
||||
return self::RECEIVED_STATUSES[$this->status] ?? $this->status;
|
||||
$statuses = $isCheck ? self::RECEIVED_CHECK_STATUSES : self::RECEIVED_STATUSES;
|
||||
|
||||
return $statuses[$this->status] ?? self::RECEIVED_STATUSES[$this->status] ?? $this->status;
|
||||
}
|
||||
|
||||
return self::ISSUED_STATUSES[$this->status] ?? $this->status;
|
||||
$statuses = $isCheck ? self::ISSUED_CHECK_STATUSES : self::ISSUED_STATUSES;
|
||||
|
||||
return $statuses[$this->status] ?? self::ISSUED_STATUSES[$this->status] ?? $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 증권종류 라벨
|
||||
*/
|
||||
public function getInstrumentTypeLabelAttribute(): string
|
||||
{
|
||||
return self::INSTRUMENT_TYPES[$this->instrument_type] ?? $this->instrument_type ?? '약속어음';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,8 +12,10 @@ class BillInstallment extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'bill_id',
|
||||
'type',
|
||||
'installment_date',
|
||||
'amount',
|
||||
'counterparty',
|
||||
'note',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
@@ -34,6 +34,7 @@ class ExpenseAccount extends Model
|
||||
'vendor_name',
|
||||
'payment_method',
|
||||
'card_no',
|
||||
'loan_id',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
@@ -53,6 +54,9 @@ class ExpenseAccount extends Model
|
||||
|
||||
public const TYPE_OFFICE = 'office';
|
||||
|
||||
// 세부 유형 상수 (접대비)
|
||||
public const SUB_TYPE_GIFT_CERTIFICATE = 'gift_certificate';
|
||||
|
||||
// 세부 유형 상수 (복리후생)
|
||||
public const SUB_TYPE_MEAL = 'meal';
|
||||
|
||||
|
||||
53
app/Models/Tenants/JournalEntry.php
Normal file
53
app/Models/Tenants/JournalEntry.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class JournalEntry extends Model
|
||||
{
|
||||
use BelongsToTenant, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'entry_no',
|
||||
'entry_date',
|
||||
'entry_type',
|
||||
'description',
|
||||
'total_debit',
|
||||
'total_credit',
|
||||
'status',
|
||||
'source_type',
|
||||
'source_key',
|
||||
'created_by_name',
|
||||
'attachment_note',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'entry_date' => 'date',
|
||||
'total_debit' => 'integer',
|
||||
'total_credit' => 'integer',
|
||||
];
|
||||
|
||||
// Status
|
||||
public const STATUS_DRAFT = 'draft';
|
||||
public const STATUS_CONFIRMED = 'confirmed';
|
||||
|
||||
// Source type
|
||||
public const SOURCE_MANUAL = 'manual';
|
||||
public const SOURCE_BANK_TRANSACTION = 'bank_transaction';
|
||||
|
||||
// Entry type
|
||||
public const TYPE_GENERAL = 'general';
|
||||
|
||||
/**
|
||||
* 분개 행 관계
|
||||
*/
|
||||
public function lines(): HasMany
|
||||
{
|
||||
return $this->hasMany(JournalEntryLine::class)->orderBy('line_no');
|
||||
}
|
||||
}
|
||||
45
app/Models/Tenants/JournalEntryLine.php
Normal file
45
app/Models/Tenants/JournalEntryLine.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenants;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class JournalEntryLine extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'journal_entry_id',
|
||||
'line_no',
|
||||
'dc_type',
|
||||
'account_code',
|
||||
'account_name',
|
||||
'trading_partner_id',
|
||||
'trading_partner_name',
|
||||
'debit_amount',
|
||||
'credit_amount',
|
||||
'description',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'line_no' => 'integer',
|
||||
'debit_amount' => 'integer',
|
||||
'credit_amount' => 'integer',
|
||||
'trading_partner_id' => 'integer',
|
||||
];
|
||||
|
||||
// DC Type
|
||||
public const DC_DEBIT = 'debit';
|
||||
public const DC_CREDIT = 'credit';
|
||||
|
||||
/**
|
||||
* 전표 관계
|
||||
*/
|
||||
public function journalEntry(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(JournalEntry::class);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,12 @@ class Loan extends Model
|
||||
|
||||
public const STATUS_PARTIAL = 'partial'; // 부분정산
|
||||
|
||||
public const STATUS_HOLDING = 'holding'; // 보유 (상품권)
|
||||
|
||||
public const STATUS_USED = 'used'; // 사용 (상품권)
|
||||
|
||||
public const STATUS_DISPOSED = 'disposed'; // 폐기 (상품권)
|
||||
|
||||
/**
|
||||
* 상태 목록
|
||||
*/
|
||||
@@ -35,6 +41,40 @@ class Loan extends Model
|
||||
self::STATUS_OUTSTANDING,
|
||||
self::STATUS_SETTLED,
|
||||
self::STATUS_PARTIAL,
|
||||
self::STATUS_HOLDING,
|
||||
self::STATUS_USED,
|
||||
self::STATUS_DISPOSED,
|
||||
];
|
||||
|
||||
/**
|
||||
* 카테고리 상수 (D1.7 기획서)
|
||||
*/
|
||||
public const CATEGORY_CARD = 'card'; // 카드
|
||||
|
||||
public const CATEGORY_CONGRATULATORY = 'congratulatory'; // 경조사
|
||||
|
||||
public const CATEGORY_GIFT_CERTIFICATE = 'gift_certificate'; // 상품권
|
||||
|
||||
public const CATEGORY_ENTERTAINMENT = 'entertainment'; // 접대비
|
||||
|
||||
/**
|
||||
* 카테고리 목록
|
||||
*/
|
||||
public const CATEGORIES = [
|
||||
self::CATEGORY_CARD,
|
||||
self::CATEGORY_CONGRATULATORY,
|
||||
self::CATEGORY_GIFT_CERTIFICATE,
|
||||
self::CATEGORY_ENTERTAINMENT,
|
||||
];
|
||||
|
||||
/**
|
||||
* 카테고리 라벨 매핑
|
||||
*/
|
||||
public const CATEGORY_LABELS = [
|
||||
self::CATEGORY_CARD => '카드',
|
||||
self::CATEGORY_CONGRATULATORY => '경조사',
|
||||
self::CATEGORY_GIFT_CERTIFICATE => '상품권',
|
||||
self::CATEGORY_ENTERTAINMENT => '접대비',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -72,6 +112,8 @@ class Loan extends Model
|
||||
'settlement_date',
|
||||
'settlement_amount',
|
||||
'status',
|
||||
'category',
|
||||
'metadata',
|
||||
'withdrawal_id',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
@@ -83,6 +125,7 @@ class Loan extends Model
|
||||
'settlement_date' => 'date',
|
||||
'amount' => 'decimal:2',
|
||||
'settlement_amount' => 'decimal:2',
|
||||
'metadata' => 'array',
|
||||
];
|
||||
|
||||
// =========================================================================
|
||||
@@ -134,10 +177,21 @@ public function getStatusLabelAttribute(): string
|
||||
self::STATUS_OUTSTANDING => '미정산',
|
||||
self::STATUS_SETTLED => '정산완료',
|
||||
self::STATUS_PARTIAL => '부분정산',
|
||||
self::STATUS_HOLDING => '보유',
|
||||
self::STATUS_USED => '사용',
|
||||
self::STATUS_DISPOSED => '폐기',
|
||||
default => $this->status,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 카테고리 라벨
|
||||
*/
|
||||
public function getCategoryLabelAttribute(): string
|
||||
{
|
||||
return self::CATEGORY_LABELS[$this->category] ?? $this->category ?? '카드';
|
||||
}
|
||||
|
||||
/**
|
||||
* 미정산 잔액
|
||||
*/
|
||||
@@ -165,19 +219,33 @@ public function getElapsedDaysAttribute(): int
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 수정 가능 여부 (미정산 상태만)
|
||||
* 수정 가능 여부 (미정산 상태 또는 상품권)
|
||||
*/
|
||||
public function isEditable(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_OUTSTANDING;
|
||||
if ($this->category === self::CATEGORY_GIFT_CERTIFICATE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array($this->status, [
|
||||
self::STATUS_OUTSTANDING,
|
||||
self::STATUS_HOLDING,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 삭제 가능 여부 (미정산 상태만)
|
||||
* 삭제 가능 여부 (미정산/보유 상태 또는 상품권)
|
||||
*/
|
||||
public function isDeletable(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_OUTSTANDING;
|
||||
if ($this->category === self::CATEGORY_GIFT_CERTIFICATE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array($this->status, [
|
||||
self::STATUS_OUTSTANDING,
|
||||
self::STATUS_HOLDING,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user